繁体   English   中英

使用Grunt和Webpack的结构

[英]Structure for using Grunt and Webpack

我有一个典型的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
        })
    ]
};

但是我仍然想使用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
        })
    ]
    };

现在明显的问题是,当我运行grunt build时,它无法识别对ExtractTextPlugin的引用。 那么,现在我该在哪里声明不能使用webpack.config?

如果我要解决所有这些错误,请让我知道,因为我只是在学习Webpack。

您只需要自己要求它:

var ExtractTextPlugin = require("extract-text-webpack-plugin");

暂无
暂无

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

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