当我试图跟随使用说明使用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-加载程序’})
变到
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:
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')
}
})
]
}还有其他人见过这种行为吗?
发布于 2017-04-18 06:55:04
我也有同样的问题。在package.json "extract-text-webpack-plugin": "~0.8.0"中设置,然后像loader: ExtractTextPlugin.extract('style', 'css!less')一样定义ExtractTextPlugin加载程序。
https://stackoverflow.com/questions/42657801
复制相似问题