简体   繁体   English

如何使用 uglifyjs-webpack 将源文件 (Javascript) 缩小为缩小文件

[英]How to minify a source file (Javascript) into a minify file using uglifyjs-webpack

I want to minify my files using uglifyjs-webpack.我想使用 uglifyjs-webpack 缩小我的文件。

For example I have a source file core/js/test and want to minify it and send it to min/js/test .例如,我有一个源文件core/js/test并希望将其缩小并将其发送到min/js/test

Just using a source and respective output, how do I use it with webpack.仅使用源和相应的输出,我如何将它与 webpack 一起使用。

I often just use the optimization: {minimize: true} option ( see this ) since webpack 4.从 webpack 4 开始,我经常只使用optimization: {minimize: true}选项( 见这个)。

const path = require("path"); 

module.exports = {
  context: __dirname,
  entry: "/origin/main.js",
  output: {
      path: path.resolve("./min/js/"),
      filename: "test.js"
  },
  optimization: {
    minimize: false
  }
};

However, webpack still allows you to override the default implementation using the UglifyjsWebpackPlugin .但是,webpack 仍然允许您使用UglifyjsWebpackPlugin覆盖默认实现。 I'd advise you to have a look at the docs in here , they seem to explain it quite alright.我建议你看看这里的文档,他们似乎解释得很好。

You might like this web site.你可能会喜欢这个网站。 It will help you to minify.它会帮助你缩小。 minifier缩小器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM