mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
|
|
import WindiCSSWebpackPlugin from 'windicss-webpack-plugin';
|
|
|
|
export default (api) => {
|
|
api.describe({
|
|
key: 'windicss',
|
|
config: {
|
|
schema(joi) {
|
|
return joi.object();
|
|
},
|
|
default: {}
|
|
}
|
|
});
|
|
|
|
api.addEntryImportsAhead(() => [{ source: 'windi-base.css' }, { source: 'windi-components.css' }, { source: 'windi-utilities.css' }]);
|
|
|
|
api.chainWebpack((memo, { createCSSRule }) => {
|
|
const { config, ...otherOption } = api.config.windicss;
|
|
memo.plugin('windicss').use(WindiCSSWebpackPlugin, [
|
|
{
|
|
config: {
|
|
extract: {
|
|
// A common use case is scanning files from the root directory
|
|
include: ['**/*.{vue,jsx,js,ts,tsx}'],
|
|
// if you are excluding files, make sure you always include node_modules and .git
|
|
exclude: ['node_modules', '.git', 'dist']
|
|
},
|
|
...config
|
|
},
|
|
...otherOption
|
|
}
|
|
]);
|
|
if (api.env === 'development') {
|
|
memo.module.rule('css').test((path) => {
|
|
if (path.endsWith('windi-utilities.css')) {
|
|
return false;
|
|
}
|
|
return /\.css$/.test(path);
|
|
});
|
|
createCSSRule({
|
|
lang: 'windicss',
|
|
test: /windi-utilities.css$/,
|
|
styleLoaderOption: {
|
|
insert: 'body'
|
|
}
|
|
});
|
|
}
|
|
|
|
return memo;
|
|
});
|
|
};
|