我正在使用带有样式加载器,css-loader和文件加载器的webpack。当我的CSS被提取到一个单独的CSS文件中时,网址都会转换成如下所示。
background-image:url([object Object]); ......... content:url([object Object]);
我的webpack.js文件如下所示,
plugins: [ new ExtractTextPlugin("styles_[hash].css") ],
module: {
rules: [{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
},
{
test: /\.(png|jpg|gif|svg|cur)$/,
use: [
{
loader: 'file-loader',
options: {
name : '[name]_[hash].[ext]',
useRelativePath : true
}
}
]
},
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{ test: /\.tsx?$/, loader: "awesome-typescript-loader"},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
]
},
我使用ExtractTextWebpackPlugin并将其传递给插件数组