mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 23:57:22 +02:00
feat: add .css webpack loader
This commit is contained in:
parent
ea706d2830
commit
1564edae4c
9 changed files with 202 additions and 41 deletions
|
@ -1,4 +1,5 @@
|
|||
const Config = require('webpack-chain');
|
||||
const CSSExtractPlugin = require('mini-css-extract-plugin');
|
||||
const path = require('path');
|
||||
|
||||
const mdLoader = require.resolve('./loader/markdown');
|
||||
|
@ -71,5 +72,30 @@ module.exports = function createBaseConfig(props) {
|
|||
.loader(mdLoader)
|
||||
.options({siteConfig});
|
||||
|
||||
const cssRule = config.module.rule('css').test(/\.css$/);
|
||||
if (isProd) {
|
||||
cssRule.use('extract-css-loader').loader(CSSExtractPlugin.loader);
|
||||
} else {
|
||||
cssRule.use('style-loader').loader('style-loader');
|
||||
}
|
||||
cssRule
|
||||
.use('css-loader')
|
||||
.loader('css-loader')
|
||||
.options({
|
||||
modules: true,
|
||||
importLoaders: 1,
|
||||
localIdentName: `[local]_[hash:base64:8]`,
|
||||
sourceMap: !isProd,
|
||||
minimize: true
|
||||
});
|
||||
|
||||
// mini-css-extract plugin
|
||||
config.plugin('extract-css').use(CSSExtractPlugin, [
|
||||
{
|
||||
filename: isProd ? '[name].[chunkhash].css' : '[name].css',
|
||||
chunkFilename: isProd ? '[id].[chunkhash].css' : '[id].css'
|
||||
}
|
||||
]);
|
||||
|
||||
return config;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue