gpt4 book ai didi

vue.js - webpack运行构建但不退出命令

转载 作者:行者123 更新时间:2023-12-03 06:36:15 26 4
gpt4 key购买 nike

Webpack成功运行了构建,但之后无法自动退出命令。如何退出?

删除--progress和webpack-dashboard,仍然不能

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",

链接运行这个
npm run build

我希望成功构建后可以退出命令, not like this image

最佳答案

将此添加到您的webpack.base.conf.js

plugins: [
// your plugins...
{
apply: (compiler) => {
compiler.hooks.done.tap('DonePlugin', (stats) => {
console.log('Compile is done !')
setTimeout(() => {
process.exit(0)
})
});
}
}
]
这使用了webpack的编译器 Hook ,
https://webpack.js.org/api/compiler-hooks/#done

关于vue.js - webpack运行构建但不退出命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56053159/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com