forked from apertureless/vue-chartjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apertureless#227 from kingkong64/develop
update webpack to version 3
- Loading branch information
Showing
36 changed files
with
46,572 additions
and
35,110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,41 @@ | ||
// https://github.com/shelljs/shelljs | ||
require('shelljs/global') | ||
env.NODE_ENV = 'production' | ||
'use strict' | ||
require('./check-versions')() | ||
|
||
var path = require('path') | ||
var config = require('../config') | ||
var ora = require('ora') | ||
var webpack = require('webpack') | ||
var webpackConfig = require('./webpack.prod.conf') | ||
process.env.NODE_ENV = 'production' | ||
|
||
console.log( | ||
' Tip:\n' + | ||
' Built files are meant to be served over an HTTP server.\n' + | ||
' Opening index.html over file:// won\'t work.\n' | ||
) | ||
const ora = require('ora') | ||
const rm = require('rimraf') | ||
const path = require('path') | ||
const chalk = require('chalk') | ||
const webpack = require('webpack') | ||
const config = require('../config') | ||
const webpackConfig = require('./webpack.prod.conf') | ||
|
||
var spinner = ora('building UMD module...') | ||
const spinner = ora('building for production...') | ||
spinner.start() | ||
|
||
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory) | ||
rm('-rf', assetsPath) | ||
mkdir('-p', assetsPath) | ||
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { | ||
if (err) throw err | ||
webpack(webpackConfig, function (err, stats) { | ||
spinner.stop() | ||
if (err) throw err | ||
process.stdout.write(stats.toString({ | ||
colors: true, | ||
modules: false, | ||
children: false, | ||
chunks: false, | ||
chunkModules: false | ||
}) + '\n\n') | ||
|
||
if (stats.hasErrors()) { | ||
console.log(chalk.red(' Build failed with errors.\n')) | ||
process.exit(1) | ||
} | ||
|
||
webpack(webpackConfig, function (err, stats) { | ||
spinner.stop() | ||
if (err) throw err | ||
process.stdout.write(stats.toString({ | ||
colors: true, | ||
modules: false, | ||
children: false, | ||
chunks: false, | ||
chunkModules: false | ||
}) + '\n') | ||
console.log(chalk.cyan(' Build complete.\n')) | ||
console.log(chalk.yellow( | ||
' Tip: built files are meant to be served over an HTTP server.\n' + | ||
' Opening index.html over file:// won\'t work.\n' | ||
)) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict' | ||
const chalk = require('chalk') | ||
const semver = require('semver') | ||
const packageConfig = require('../package.json') | ||
const shell = require('shelljs') | ||
function exec (cmd) { | ||
return require('child_process').execSync(cmd).toString().trim() | ||
} | ||
|
||
const versionRequirements = [ | ||
{ | ||
name: 'node', | ||
currentVersion: semver.clean(process.version), | ||
versionRequirement: packageConfig.engines.node | ||
} | ||
] | ||
|
||
if (shell.which('npm')) { | ||
versionRequirements.push({ | ||
name: 'npm', | ||
currentVersion: exec('npm --version'), | ||
versionRequirement: packageConfig.engines.npm | ||
}) | ||
} | ||
|
||
module.exports = function () { | ||
const warnings = [] | ||
for (let i = 0; i < versionRequirements.length; i++) { | ||
const mod = versionRequirements[i] | ||
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { | ||
warnings.push(mod.name + ': ' + | ||
chalk.red(mod.currentVersion) + ' should be ' + | ||
chalk.green(mod.versionRequirement) | ||
) | ||
} | ||
} | ||
|
||
if (warnings.length) { | ||
console.log('') | ||
console.log(chalk.yellow('To use this template, you must update following to modules:')) | ||
console.log() | ||
for (let i = 0; i < warnings.length; i++) { | ||
const warning = warnings[i] | ||
console.log(' ' + warning) | ||
} | ||
console.log() | ||
process.exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict' | ||
const utils = require('./utils') | ||
const config = require('../config') | ||
const isProduction = process.env.NODE_ENV === 'production' | ||
|
||
module.exports = { | ||
loaders: utils.cssLoaders({ | ||
sourceMap: isProduction | ||
? config.build.productionSourceMap | ||
: config.dev.cssSourceMap, | ||
extract: isProduction | ||
}), | ||
transformToRequire: { | ||
video: 'src', | ||
source: 'src', | ||
img: 'src', | ||
image: 'xlink:href' | ||
} | ||
} |
Oops, something went wrong.