Package to fix style (css/sass/less/stylus) only entries generating a extra js file.
npm install webpack-fix-style-only-entries
npm install -D webpack-fix-style-only-entries
yarn add -D webpack-fix-style-only-entries
javascript
// ... other plugins
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const FixStyleOnlyEntriesPlugin = require("webpack-fix-style-only-entries");
module.exports = {
entry: {
"main" : "./app/main.js"
"styles": ["./common/styles.css", "./app/styles.css"]
},
module: {
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
]
},
]
},
plugins: [
new FixStyleOnlyEntriesPlugin(),
new MiniCssExtractPlugin({
filename: "[name].[chunkhash:8].css",
}),
],
};
`
Options
| Name | Type | Default | Description |
|------------|--------------- |----------------------------------------|-------------|
| extensions | Array[string] | ["less", "scss", "css", "styl","sass"] | file extensions for styles |
| silent | boolean | false | supress logs to console |
| ignore | string or RegExp | undefined | match resource to be ignored |
$3
// to identify only 'foo' and 'bar' extensions as styles
new FixStyleOnlyEntriesPlugin({ extensions:['foo', 'bar'] }),
Recipes
$3
Give an especial extension to your file (.css.js for example) and configure new FixStyleOnlyEntriesPlugin({ extensions:['css.js'] }). See: https://github.com/fqborges/webpack-fix-style-only-entries/issues/8.
$3
Configure this plugin as new FixStyleOnlyEntriesPlugin({ ignore: 'webpack-hot-middleware' })`. See: https://github.com/fqborges/webpack-fix-style-only-entries/issues/12 and https://github.com/fqborges/webpack-fix-style-only-entries/blob/master/test/cases/css-entry-with-ignored-hmr/webpack.config.js.