向webpack添加命令以预处理js

时间:2016-06-22 03:23:10

标签: webpack

我有preprocess bundle.js . -FULL=true > bundle.full.jshttps://www.npmjs.com/package/preprocessor)来运行javascript的预处理。我的webpack.config.js在下面,

var webpack = require('webpack');
var PROD = JSON.parse(process.env.PROD_ENV || '0');

module.exports = {
    entry: "./bootstrap.js",
    devtool: 'source-map',
    output: {
        path: __dirname,
        filename: PROD ? 'bundle.min.js' : 'bundle.js'
    },
    plugins: PROD ? [
        new webpack.optimize.UglifyJsPlugin({
            compress: { warnings: false }
        })
    ] : [],
    module: {
        loaders: [
            { test: /\.css$/, loader: "style!css" }
        ]
    }
}; 

如何将预处理命令添加到配置中以使其自动运行?

1 个答案:

答案 0 :(得分:0)

您可以安装preprocess-loader npm install preprocess-loader --save-dev

将您的webpack.config.js更改为: module: { loaders: [{ test: /\.css$/, loader: "style!css!preprocess?+FULL" }] }

有关详细信息,请查看:

  • npm上的预处理加载程序
  • github上的预处理加载程序