初次使用ExtractTextPlugin,发现单独打包css时失效(打包结束后的built路径下,没有app.css文件):
module.exports = {
entry:{
main:"./app/index.jsx",
vendor:[
"react",
"react-dom",
"react-router",
"react-bootstrap",
"underscore",
]
},
output: {
path: path.resolve(__dirname, './built'),
filename: '[name].js?[chunkhash]',
chunkFilename: '[name].js?[chunkhash]',
publicPath: './built/'
},
resolve: {
// modulesDirectories: [ 'node_modules' ],
extensions: ['.js', '.jsx']
},
module: {
loaders: [
{
test: /\.jsx|js$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/,
query: {
presets: ['es2015', 'react']
}
},
{
test: /\.css|scss$/,
loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css!scss' })
},
{
test: /\.png|jpg|gif|jpeg$/,
loader: "url-loader?limit=8194&name=img/[name].[ext]",
query: 'random=' + new Date().getTime(),
},
{
test: /\.json$/,
loader: "json"
}
],
},
plugins:[
new ExtractTextPlugin({ filename: './app.css', disable: false, allChunks: true })
]
}
你把这个{ filename: './app.css', disable: false, allChunks: true }换成直接的路径试试
例如 (‘css/[name].css’)