Webpack successfully run build, but can't auto exit command after. How to exit?
remove --progress and webpack-dashboard,still can't
webpack.base.conf.js
...// require
module.exports = {
mode: process.env.NODE_ENV,
entry: {
app: './src/main.js',
},
output: {
path: util.resolve('dist'),
filename: 'js/[name].[hash].js',
chunkFilename: 'js/[id].[chunkhash].js',
},
module: {
rules: [
...util.eslint,
...util.cssLoaders,
// more loaders
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, '../public/index.html'),
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
},
}),
new DllLinkPlugin({
htmlMode: true,
config: require('./webpack.dll.conf.js'),
}),
],
stats: {
children: false,
builtAt: true,
cached: true,
cachedAssets: true
}
};
webpack.prod.conf.js
// requere...
const config = require('./webpack.base.conf');
const env = require('../env.production')
module.exports = merge(config, {
bail: true,
watch:false,
devtool: 'cheap-module-source-map',
plugins: [
// ... mini css html
new CompressionWebpackPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
})
],
optimization: {
... options
}
});
package.json
"build": "cross-env NODE_ENV=production webpack --progress --config build/webpack.prod.conf.js",
link run this
npm run build
i expect exit command after Successfully build ,not like this image
add this to your webpack.base.conf.js
plugins: [
// your plugins...
{
apply: (compiler) => {
compiler.hooks.done.tap('DonePlugin', (stats) => {
console.log('Compile is done !')
setTimeout(() => {
process.exit(0)
})
});
}
}
]
This use webpack's compiler hooks, https://webpack.js.org/api/compiler-hooks/#done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With