I am trying to get css requires to work in webpack using the ExtractTextPlugin but with no success
I want a separate css file rather than inlining any css.
Here's a webpack.config.js that works. I don't use the same directory names you do, but I think you can see the differences and make the needed changes. I'm also including my current module versions.
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const config = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'bundle.js',
publicPath: 'build/'
},
module: {
rules: [
{
use: 'babel-loader',
test: /\.js$/
},
{
loader: ExtractTextPlugin.extract({fallback: 'style-loader', use: 'css-loader'}),
test: /\.css$/
},
{
test: /\.(jpe?g|png|gif|svg)$/,
use: [
{
loader: 'url-loader',
options: { limit: 40000 }
},
'image-webpack-loader?bypassOnDebug'
]
}
]
},
plugins: [
new ExtractTextPlugin({filename: 'style.css',
allChunks: true
})
]
};
module.exports = config;
// and modules:
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^6.4.1",
"babel-preset-env": "^1.3.3",
"css-loader": "^0.28.0",
"extract-text-webpack-plugin": "^2.0.0-beta.4",
"file-loader": "^0.11.1",
"image-webpack-loader": "^3.3.0",
"style-loader": "^0.16.1",
"url-loader": "^0.5.8",
"webpack": "^2.2.0-rc.0"
}