I’m slowly bringing Webpack into an existing project. At this point we won’t require
.css files. However, I would like Webpack to still process them.
I would like Webpack to just load the file, pass it to whatever .css loader is required (Stylus in our case), and output a .css file.
None of the combinations of ExtractTextPlugin, raw and file loaders, passing loaders into other loaders work, Webpack inevitably throws
Module build failed: ParseError: ...bootstrap-theme.min.css:5:1996
1| /*!
2| * Bootstrap v3.3.5 (http://getbootstrap.com)
3| * Copyright 2011-2015 Twitter, Inc.
...
expected "indent", got ";"
Is it even possible to process external files with Webpack like this?
Various combinations tried:
{
test: /.(styl|css)/,
loader: 'raw!stylus'
}
{
test: /.(styl|css)/,
loader: 'file!stylus'
}
{
test: /.(styl|css)/,
loader: ExtractTextPlugin.extract('file', 'raw!stylus')
}
{
test: /.(styl|css)/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!stylus-loader')
}
2
Answers
You don’t need to pass your css files through the stylus loader, only the .styl files.
I’ve managed to make it work with this configuration:
And then you can import/require your css files as such:
You could also add your CSS as an extra entry point of
name
: