Clean build folder
Former-commit-id: e47639684bbb1b4d0a15ac8c39dbb0040ae86226 [formerly 3343000db072beb88cec31bb52b139313469f612] [formerly 062dd709613b5784dc8e9b2f327df3cd4c95dc75 [formerly 69d8cd6343
]]
Former-commit-id: 1c0ebd340266b2020ffba94d2370dbf7c98d1aa6 [formerly fcf840509a0f782b8460fb354aed513dbaa10aa2]
Former-commit-id: bd4e275034627c7ff9c8b60c1405ce6aed912761
pull/726/head
parent
e05e8e2b8b
commit
bd341f3ffc
|
@ -13,7 +13,7 @@ var webpackConfig = require('./webpack.prod.conf')
|
||||||
var spinner = ora('building for production...')
|
var spinner = ora('building for production...')
|
||||||
spinner.start()
|
spinner.start()
|
||||||
|
|
||||||
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
|
rm(path.join(config.assetsRoot, config.assetsSubDirectory), err => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
webpack(webpackConfig, function (err, stats) {
|
webpack(webpackConfig, function (err, stats) {
|
||||||
spinner.stop()
|
spinner.stop()
|
||||||
|
@ -27,9 +27,5 @@ rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
|
||||||
}) + '\n\n')
|
}) + '\n\n')
|
||||||
|
|
||||||
console.log(chalk.cyan(' Build complete.\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'
|
|
||||||
))
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,21 +2,15 @@
|
||||||
var path = require('path')
|
var path = require('path')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
build: {
|
|
||||||
env: {
|
|
||||||
NODE_ENV: '"production"'
|
|
||||||
},
|
|
||||||
index: path.resolve(__dirname, '../dist/index.html'),
|
index: path.resolve(__dirname, '../dist/index.html'),
|
||||||
assetsRoot: path.resolve(__dirname, '../dist'),
|
assetsRoot: path.resolve(__dirname, '../dist'),
|
||||||
assetsSubDirectory: 'static',
|
assetsSubDirectory: 'static',
|
||||||
assetsPublicPath: '{{ .BaseURL }}/',
|
assetsPublicPath: '{{ .BaseURL }}/',
|
||||||
|
build: {
|
||||||
|
env: {
|
||||||
|
NODE_ENV: '"production"'
|
||||||
|
},
|
||||||
productionSourceMap: true,
|
productionSourceMap: true,
|
||||||
// Gzip off by default as many popular static hosts such as
|
|
||||||
// Surge or Netlify already gzip all static assets for you.
|
|
||||||
// Before setting to `true`, make sure to:
|
|
||||||
// npm install --save-dev compression-webpack-plugin
|
|
||||||
productionGzip: false,
|
|
||||||
productionGzipExtensions: ['js', 'css'],
|
|
||||||
// Run the build command with an extra argument to
|
// Run the build command with an extra argument to
|
||||||
// View the bundle analyzer report after build finishes:
|
// View the bundle analyzer report after build finishes:
|
||||||
// `npm run build --report`
|
// `npm run build --report`
|
||||||
|
@ -27,10 +21,6 @@ module.exports = {
|
||||||
env: {
|
env: {
|
||||||
NODE_ENV: '"development"'
|
NODE_ENV: '"development"'
|
||||||
},
|
},
|
||||||
index: path.resolve(__dirname, '../dist/index.html'),
|
|
||||||
assetsRoot: path.resolve(__dirname, '../dist/'),
|
|
||||||
assetsSubDirectory: 'static',
|
|
||||||
assetsPublicPath: '{{ .BaseURL }}/',
|
|
||||||
produceSourceMap: true
|
produceSourceMap: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ var webpack = require('webpack')
|
||||||
var config = require('./config')
|
var config = require('./config')
|
||||||
var webpackConfig = require('./webpack.dev.conf')
|
var webpackConfig = require('./webpack.dev.conf')
|
||||||
|
|
||||||
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
|
rm(path.join(config.assetsRoot, config.assetsSubDirectory), err => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
webpack(webpackConfig, function (err, stats) {
|
webpack(webpackConfig, function (err, stats) {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
|
|
|
@ -3,9 +3,7 @@ var config = require('./config')
|
||||||
var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
||||||
|
|
||||||
exports.assetsPath = function (_path) {
|
exports.assetsPath = function (_path) {
|
||||||
var assetsSubDirectory = process.env.NODE_ENV === 'production'
|
var assetsSubDirectory = config.assetsSubDirectory
|
||||||
? config.build.assetsSubDirectory
|
|
||||||
: config.dev.assetsSubDirectory
|
|
||||||
|
|
||||||
return path.posix.join(assetsSubDirectory, _path)
|
return path.posix.join(assetsSubDirectory, _path)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
||||||
loaders: utils.cssLoaders({
|
loaders: utils.cssLoaders({
|
||||||
sourceMap: isProduction
|
sourceMap: isProduction
|
||||||
? config.build.productionSourceMap
|
? config.build.productionSourceMap
|
||||||
: config.dev.cssSourceMap,
|
: config.dev.produceSourceMap,
|
||||||
extract: isProduction
|
extract: isProduction
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,9 @@ module.exports = {
|
||||||
app: './assets/src/main.js'
|
app: './assets/src/main.js'
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: config.build.assetsRoot,
|
path: config.assetsRoot,
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
publicPath: process.env.NODE_ENV === 'production'
|
publicPath: config.assetsPublicPath
|
||||||
? config.build.assetsPublicPath
|
|
||||||
: config.dev.assetsPublicPath
|
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js', '.vue', '.json'],
|
extensions: ['.js', '.vue', '.json'],
|
||||||
|
|
|
@ -39,7 +39,7 @@ module.exports = merge(baseWebpackConfig, {
|
||||||
// see https://github.com/ampedandwired/html-webpack-plugin
|
// see https://github.com/ampedandwired/html-webpack-plugin
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
filename: config.dev.index,
|
filename: config.dev.index,
|
||||||
template: 'index.html',
|
template: 'assets/index.html',
|
||||||
inject: true,
|
inject: true,
|
||||||
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
|
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
|
||||||
chunksSortMode: 'dependency',
|
chunksSortMode: 'dependency',
|
||||||
|
@ -69,12 +69,12 @@ module.exports = merge(baseWebpackConfig, {
|
||||||
new CopyWebpackPlugin([
|
new CopyWebpackPlugin([
|
||||||
{
|
{
|
||||||
from: path.resolve(__dirname, '../static'),
|
from: path.resolve(__dirname, '../static'),
|
||||||
to: config.dev.assetsSubDirectory,
|
to: config.assetsSubDirectory,
|
||||||
ignore: ['.*']
|
ignore: ['.*']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
from: path.resolve(__dirname, '../node_modules/codemirror/mode/*/*'),
|
from: path.resolve(__dirname, '../node_modules/codemirror/mode/*/*'),
|
||||||
to: path.join(config.build.assetsSubDirectory, 'js/codemirror/mode/[name]/[name].js')
|
to: path.join(config.assetsSubDirectory, 'js/codemirror/mode/[name]/[name].js')
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
|
|
|
@ -23,7 +23,7 @@ var webpackConfig = merge(baseWebpackConfig, {
|
||||||
},
|
},
|
||||||
devtool: config.build.productionSourceMap ? '#source-map' : false,
|
devtool: config.build.productionSourceMap ? '#source-map' : false,
|
||||||
output: {
|
output: {
|
||||||
path: config.build.assetsRoot,
|
path: config.assetsRoot,
|
||||||
filename: utils.assetsPath('js/[name].[chunkhash].js'),
|
filename: utils.assetsPath('js/[name].[chunkhash].js'),
|
||||||
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
|
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
|
||||||
},
|
},
|
||||||
|
@ -31,12 +31,12 @@ var webpackConfig = merge(baseWebpackConfig, {
|
||||||
new CopyWebpackPlugin([
|
new CopyWebpackPlugin([
|
||||||
{
|
{
|
||||||
from: path.resolve(__dirname, '../static'),
|
from: path.resolve(__dirname, '../static'),
|
||||||
to: config.dev.assetsSubDirectory,
|
to: config.assetsSubDirectory,
|
||||||
ignore: ['.*']
|
ignore: ['.*']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
from: path.resolve(__dirname, '../node_modules/codemirror/mode/*/*'),
|
from: path.resolve(__dirname, '../node_modules/codemirror/mode/*/*'),
|
||||||
to: path.join(config.build.assetsSubDirectory, 'js/codemirror/mode/[name]/[name].js'),
|
to: path.join(config.assetsSubDirectory, 'js/codemirror/mode/[name]/[name].js'),
|
||||||
transform: function (source, path) {
|
transform: function (source, path) {
|
||||||
let result = UglifyJS.minify(source.toString('utf8'))
|
let result = UglifyJS.minify(source.toString('utf8'))
|
||||||
if (result.error !== undefined) {
|
if (result.error !== undefined) {
|
||||||
|
@ -71,7 +71,7 @@ var webpackConfig = merge(baseWebpackConfig, {
|
||||||
// you can customize output by editing /index.html
|
// you can customize output by editing /index.html
|
||||||
// see https://github.com/ampedandwired/html-webpack-plugin
|
// see https://github.com/ampedandwired/html-webpack-plugin
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
filename: config.build.index,
|
filename: config.index,
|
||||||
template: 'assets/index.html',
|
template: 'assets/index.html',
|
||||||
inject: true,
|
inject: true,
|
||||||
minify: {
|
minify: {
|
||||||
|
@ -119,24 +119,6 @@ var webpackConfig = merge(baseWebpackConfig, {
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
if (config.build.productionGzip) {
|
|
||||||
var CompressionWebpackPlugin = require('compression-webpack-plugin')
|
|
||||||
|
|
||||||
webpackConfig.plugins.push(
|
|
||||||
new CompressionWebpackPlugin({
|
|
||||||
asset: '[path].gz[query]',
|
|
||||||
algorithm: 'gzip',
|
|
||||||
test: new RegExp(
|
|
||||||
'\\.(' +
|
|
||||||
config.build.productionGzipExtensions.join('|') +
|
|
||||||
')$'
|
|
||||||
),
|
|
||||||
threshold: 10240,
|
|
||||||
minRatio: 0.8
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.build.bundleAnalyzerReport) {
|
if (config.build.bundleAnalyzerReport) {
|
||||||
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||||
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
|
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
|
||||||
|
|
Loading…
Reference in New Issue