[英]Structure for using Grunt and Webpack
I have a typical setup for Webpack like this: 我有一个典型的Webpack设置,如下所示:
// webpack.config.js
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: "./entry.js",
output: {
path: "./build",
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.scss$/, loader: ExtractTextPlugin.extract('css!sass')
}
]
},
plugins: [
new ExtractTextPlugin('style.css', {
allChunks: true
})
]
};
But I still want to use Grunt to run my builds so I'm trying to call Webpack from a Grunt task and so have moved all the settings into Grunt like this: 但是我仍然想使用Grunt来运行我的构建,所以我试图从Grunt任务调用Webpack,因此将所有设置移到Grunt中,如下所示:
// webpack.js - This is a grunt task being loaded into gruntfile.js
module.exports = {
entry: "./entry.js",
output: {
path: "./build",
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.scss$/, loader: ExtractTextPlugin.extract('css!sass') }
]
},
plugins: [
new ExtractTextPlugin('style.css', {
allChunks: true
})
]
};
The obvious issue now is when I run grunt build it doesn't recognise the reference to ExtractTextPlugin. 现在明显的问题是,当我运行grunt build时,它无法识别对ExtractTextPlugin的引用。 So where do I declare this now that I can't use webpack.config?
那么,现在我该在哪里声明不能使用webpack.config?
If I'm going about this all wrong then please let me know, as I'm just learning Webpack. 如果我要解决所有这些错误,请让我知道,因为我只是在学习Webpack。
您只需要自己要求它:
var ExtractTextPlugin = require("extract-text-webpack-plugin");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.