首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用react小部件- Webpack与摘录-文本-Webpack-插件2

如何使用react小部件- Webpack与摘录-文本-Webpack-插件2
EN

Stack Overflow用户
提问于 2017-03-07 20:33:33
回答 1查看 479关注 0票数 0

当我试图跟随使用说明使用react Webpack和extract Webpack-plugin和AC.26 2时,我会得到以下错误:

./~/react-widgets-webpack/index.loader.js!./react-widgets.config.js模块构建中的错误失败:错误:破坏更改:提取现在只使用一个参数。选项对象或加载程序。示例:如果您的旧代码如下所示: ExtractTextPlugin.extract('style-loader',‘css-加载程序’) 您可以将其更改为: ExtractTextPlugin.extract({ fallback:'style-loader',使用:‘css-加载程序’})

变到

代码语言:javascript
复制
styleLoader: require('extract-text-webpack-plugin').extract({
        fallback: "style-loader",
        use: 'css-loader!less-loader'
    })

给出以下错误:

找不到./~/react-widgets-webpack/index.loader.js!./react-widgets.config.js模块中的错误:'/Users/pbirmingham/Development/FLA/forks/flash/flash‘中无法解析“对象对象、对象对象”

我的webpack.config.js:

代码语言:javascript
复制
const webpack = require('webpack');
const globalizePlugin = require('globalize-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
    entry: {
        app: [
            'react-widgets-webpack!./react-widgets.config.js',
            'bootstrap-loader',
            './js/main.js']
    },
    output: {
        path: './public/',
        filename: 'js/bundle-[hash].js',
    },
    module: {
        rules: [
            {test: /\.(js|jsx)$/, exclude: /node_modules/, use: 'babel-loader'},
            {test: /\.json$/, use: 'json-loader'},
            {
                test: /\.(css|scss)$/,
                use: ExtractTextPlugin.extract({
                    fallback: "style-loader",
                    use: ['css-loader', 'sass-loader']
                })
            },
            {
                test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                use: "url-loader?name=[name].[hash].[ext]&limit=10000&mimetype=application/font-woff"
            },
            {test: /\.(ttf|eot|svg|gif)$/, use: "file-loader?name=[name].[hash].[ext]"},
            {test: /bootstrap.+\.(jsx|js)$/, use: 'imports-loader?jQuery=jquery,$=jquery,this=>window'}
        ]
    },
    plugins: [
        new ExtractTextPlugin({ filename: 'css/main.[contenthash].css'}),
        new globalizePlugin({
            production: false,
            developmentLocale: "en",
            supportedLocales: ["en"],
            output: "globalize-compiled-data-[locale].[hash].js"
        }),
        new HtmlWebpackPlugin({
            template: 'template/index.ejs',
            chunks: ['app']
        }),
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: JSON.stringify('production')
            }
        })
    ]
}

还有其他人见过这种行为吗?

EN

回答 1

Stack Overflow用户

发布于 2017-04-18 06:55:04

我也有同样的问题。在package.json "extract-text-webpack-plugin": "~0.8.0"中设置,然后像loader: ExtractTextPlugin.extract('style', 'css!less')一样定义ExtractTextPlugin加载程序。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42657801

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档