Open JakubKoralewski opened 5 years ago
//manifest.json
"web_accessible_resources": ["globalStyles.css"],
1. Install and Require [MiniCssExtractPlugin](https://github.com/webpack-contrib/mini-css-extract-plugin).
```javascript
\\webpack.config.js
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
options.plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: '[name].css',
chunkFilename: '[id].css'
}),
]
\\webpack.config.js
options.module.rules: [ { test: /.(s*)css$/, use: ['style-loader', 'css-loader', 'sass-loader'], exclude: /node_modules/ }, { // where globalStyles.css is the file you have declared in web_accessible_resources! test: /globalStyles.scss$/, use: [{ loader: MiniCssExtractPlugin.loader, options: { // you can specify a publicPath here // by default it use publicPath in webpackOptions.output publicPath: 'dist/' } }, 'css-loader', 'sass-loader' ] }, ]
EDIT: Problem is there is an unnecessary 'globalStyles.bundle.js' file generated.
I had to again turn to the [File Manager Webpack Plugin](https://github.com/gregnb/filemanager-webpack-plugin):
```javascript
new FileManagerWebpackPlugin({
onEnd: {
delete: ['build/globalStyles.bundle.js']
}
}),
I've done this sucessfully in my chrome extension project before changing it as per the boilerplate.
I have a CSS file and a JS file declared in the "web_accessible_resources" option. This is how I inject it inside of a content script:
Is this possible with the current state the project is in? I don't know Webpack at all, so maybe all I have to do is transfer the files I need to the /build folder somehow?
EDIT: Previously used File Manager Webpack plugin but this can be easily done with the currently used Copy Webpack Plugin.
However it would be great if this was automatically generated from the "web_accessible_resources" option in manifest.json. Additionally, I don't know how you'd apply Babel etc. to these files? Or something like SASS.
Moreover, hot reload on these files doesn't work.