Webpack.config.js file minify js and css. - 使用webpack时如何缩小js



我刚开始学习webpack,我不知道如何缩小所有文件(js和css(。我知道怎么用大口大口地做,但是网络包... 所以,我的配置文件看起来像这样:

var Encore = require('@symfony/webpack-encore');
Encore
// directory where compiled assets will be stored
.setOutputPath('public/build/')
// public path used by the web server to access the output path
.setPublicPath('/build')
.addEntry('app', './assets/js/app.js')
module.exports = Encore.getWebpackConfig();

我真的不知道如何缩小,我阅读了很多信息,但我没有得到我想要的。

您可以使用 TerserPlugin

Encore.configureTerserPlugin((options) => {
options.cache = true;
options.parallel = true;
options.terserOptions = {
output: {
comments: false,
}
}

最新更新