webpack.config.js:设置解压 css 和 javascript

webpack.config.js: setting for uncompressing css and javascript

背景:第一次见webpack.config.js

这是webpack.config.js https://github.com/marcom-unimelb/unimelb-design-system/blob/master/assets/webpack.config.js

基于上述配置生成的输出 javascript 和 css 都被缩小了。我需要对它们进行压缩,想知道我该怎么办?

我的理解是,我需要在这里做点什么。

preLoaders: [
      {
        test: /\.js$/, // include .js files
        exclude: /node_modules|vendor/, // exclude any and all files in the node_modules folder
        loader: "jshint-loader"
      }
    ],

这里:

{
        test: /\.scss$/,
        loader: ExtractTextPlugin.extract("style-loader", "css-loader?-minimize!autoprefixer-loader!sass-loader")
      },
      {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract("style-loader", "css-loader?-minimize!autoprefixer-loader")
      },

您可以在 package.json:

看到这样一行
"build": "node_modules/.bin/webpack --config ./assets/webpack.config.js -p"

正是那里的 -p 标志触发了缩小(我认为 p 代表生产)。如果您删除该标志,您将获得未缩小的版本。