-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b441541
commit 36ad197
Showing
5 changed files
with
57 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const BaseWebpackConfig = require('./baseWebpackConfig'); | ||
const moduleCSS = require('../css/modules'); | ||
const pluginCSS = require('../css/plugins'); | ||
|
||
/** | ||
* Dynamically generates webpack config for transpiling sass to css using Silverstripe default settings. | ||
* | ||
* IMPORTANT: Instead of setting the output name in the output key, add it as the filename in this constructor. | ||
* Otherwise you will get errors because webpack wants to create a js file for each css file. The js files | ||
* aren't emitted thanks to the IgnoreEmitPlugin, but this happens after chunk validation. | ||
*/ | ||
module.exports = class CssWebpackConfig extends BaseWebpackConfig { | ||
constructor(name, ENV, PATHS, filename = 'styles/[name].css') { | ||
super(); | ||
this.config = { | ||
name, | ||
output: { | ||
path: PATHS.DIST, | ||
}, | ||
devtool: (ENV !== 'production') ? 'source-map' : '', | ||
module: moduleCSS(ENV, PATHS), | ||
plugins: [ | ||
...pluginCSS(filename, ENV, PATHS), | ||
], | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin'); | ||
|
||
/** | ||
* Exports the settings for plugins in webpack.config | ||
* @param {string} filename determines the name of each output CSS file. | ||
* See https://webpack.js.org/plugins/mini-css-extract-plugin/#filename | ||
*/ | ||
module.exports = () => ([ | ||
module.exports = (filename) => ([ | ||
new MiniCssExtractPlugin({ | ||
filename: 'styles/[name].css', | ||
filename, | ||
}), | ||
new IgnoreEmitPlugin(/\.js$/), | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters