Clean build folder
parent
efcf5f077e
commit
69d8cd6343
|
@ -13,7 +13,7 @@ var webpackConfig = require('./webpack.prod.conf')
|
|||
var spinner = ora('building for production...')
|
||||
spinner.start()
|
||||
|
||||
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
|
||||
rm(path.join(config.assetsRoot, config.assetsSubDirectory), err => {
|
||||
if (err) throw err
|
||||
webpack(webpackConfig, function (err, stats) {
|
||||
spinner.stop()
|
||||
|
@ -27,9 +27,5 @@ rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
|
|||
}) + '\n\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')
|
||||
|
||||
module.exports = {
|
||||
index: path.resolve(__dirname, '../dist/index.html'),
|
||||
assetsRoot: path.resolve(__dirname, '../dist'),
|
||||
assetsSubDirectory: 'static',
|
||||
assetsPublicPath: '{{ .BaseURL }}/',
|
||||
build: {
|
||||
env: {
|
||||
NODE_ENV: '"production"'
|
||||
},
|
||||
index: path.resolve(__dirname, '../dist/index.html'),
|
||||
assetsRoot: path.resolve(__dirname, '../dist'),
|
||||
assetsSubDirectory: 'static',
|
||||
assetsPublicPath: '{{ .BaseURL }}/',
|
||||
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
|
||||
// View the bundle analyzer report after build finishes:
|
||||
// `npm run build --report`
|
||||
|
@ -27,10 +21,6 @@ module.exports = {
|
|||
env: {
|
||||
NODE_ENV: '"development"'
|
||||
},
|
||||
index: path.resolve(__dirname, '../dist/index.html'),
|
||||
assetsRoot: path.resolve(__dirname, '../dist/'),
|
||||
assetsSubDirectory: 'static',
|
||||
assetsPublicPath: '{{ .BaseURL }}/',
|
||||
produceSourceMap: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ var webpack = require('webpack')
|
|||
var config = require('./config')
|
||||
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
|
||||
webpack(webpackConfig, function (err, stats) {
|
||||
if (err) throw err
|
||||
|
|
|
@ -3,9 +3,7 @@ var config = require('./config')
|
|||
var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
||||
|
||||
exports.assetsPath = function (_path) {
|
||||
var assetsSubDirectory = process.env.NODE_ENV === 'production'
|
||||
? config.build.assetsSubDirectory
|
||||
: config.dev.assetsSubDirectory
|
||||
var assetsSubDirectory = config.assetsSubDirectory
|
||||
|
||||
return path.posix.join(assetsSubDirectory, _path)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
|||
loaders: utils.cssLoaders({
|
||||
sourceMap: isProduction
|
||||
? config.build.productionSourceMap
|
||||
: config.dev.cssSourceMap,
|
||||
: config.dev.produceSourceMap,
|
||||
extract: isProduction
|
||||
})
|
||||
}
|
||||
|
|
|
@ -12,11 +12,9 @@ module.exports = {
|
|||
app: './assets/src/main.js'
|
||||
},
|
||||
output: {
|
||||
path: config.build.assetsRoot,
|
||||
path: config.assetsRoot,
|
||||
filename: '[name].js',
|
||||
publicPath: process.env.NODE_ENV === 'production'
|
||||
? config.build.assetsPublicPath
|
||||
: config.dev.assetsPublicPath
|
||||
publicPath: config.assetsPublicPath
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js', '.vue', '.json'],
|
||||
|
|
|
@ -39,7 +39,7 @@ module.exports = merge(baseWebpackConfig, {
|
|||
// see https://github.com/ampedandwired/html-webpack-plugin
|
||||
new HtmlWebpackPlugin({
|
||||
filename: config.dev.index,
|
||||
template: 'index.html',
|
||||
template: 'assets/index.html',
|
||||
inject: true,
|
||||
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
|
||||
chunksSortMode: 'dependency',
|
||||
|
@ -69,12 +69,12 @@ module.exports = merge(baseWebpackConfig, {
|
|||
new CopyWebpackPlugin([
|
||||
{
|
||||
from: path.resolve(__dirname, '../static'),
|
||||
to: config.dev.assetsSubDirectory,
|
||||
to: config.assetsSubDirectory,
|
||||
ignore: ['.*']
|
||||
},
|
||||
{
|
||||
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,
|
||||
output: {
|
||||
path: config.build.assetsRoot,
|
||||
path: config.assetsRoot,
|
||||
filename: utils.assetsPath('js/[name].[chunkhash].js'),
|
||||
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
|
||||
},
|
||||
|
@ -31,12 +31,12 @@ var webpackConfig = merge(baseWebpackConfig, {
|
|||
new CopyWebpackPlugin([
|
||||
{
|
||||
from: path.resolve(__dirname, '../static'),
|
||||
to: config.dev.assetsSubDirectory,
|
||||
to: config.assetsSubDirectory,
|
||||
ignore: ['.*']
|
||||
},
|
||||
{
|
||||
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) {
|
||||
let result = UglifyJS.minify(source.toString('utf8'))
|
||||
if (result.error !== undefined) {
|
||||
|
@ -71,7 +71,7 @@ var webpackConfig = merge(baseWebpackConfig, {
|
|||
// you can customize output by editing /index.html
|
||||
// see https://github.com/ampedandwired/html-webpack-plugin
|
||||
new HtmlWebpackPlugin({
|
||||
filename: config.build.index,
|
||||
filename: config.index,
|
||||
template: 'assets/index.html',
|
||||
inject: true,
|
||||
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) {
|
||||
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
|
||||
|
|
Loading…
Reference in New Issue