mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
fix: 解决 windicss 在开发环境 css 加载顺序问题 (#95)
This commit is contained in:
parent
af890ad257
commit
0daa2f1a08
@ -13,15 +13,31 @@ export default (api) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
api.addEntryImportsAhead(() => [{ source: 'windi.css' }]);
|
api.addEntryImportsAhead(() => [{ source: 'windi-base.css' }, { source: 'windi-components.css' }, { source: 'windi-utilities.css' }]);
|
||||||
|
|
||||||
api.chainWebpack((memo) => {
|
api.chainWebpack((memo, { createCSSRule }) => {
|
||||||
memo.plugin('windicss').use(WindiCSSWebpackPlugin, [
|
memo.plugin('windicss').use(WindiCSSWebpackPlugin, [
|
||||||
{
|
{
|
||||||
config: resolve(__dirname, '../windi.config.js'),
|
config: resolve(__dirname, '../windi.config.js'),
|
||||||
...api.config.windicss
|
...api.config.windicss
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
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;
|
return memo;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -19,14 +19,14 @@ function createRules({
|
|||||||
test,
|
test,
|
||||||
loader,
|
loader,
|
||||||
options,
|
options,
|
||||||
browserslist
|
browserslist,
|
||||||
|
styleLoaderOption
|
||||||
}) {
|
}) {
|
||||||
function applyLoaders(rule, isCSSModules) {
|
function applyLoaders(rule, isCSSModules) {
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
rule.use('extra-css-loader')
|
rule.use('extra-css-loader')
|
||||||
.loader(require.resolve('style-loader'))
|
.loader(require.resolve('style-loader'))
|
||||||
.options({
|
.options(Object.assign({}, styleLoaderOption));
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
rule.use('extra-css-loader')
|
rule.use('extra-css-loader')
|
||||||
.loader(require('mini-css-extract-plugin').loader)
|
.loader(require('mini-css-extract-plugin').loader)
|
||||||
@ -110,13 +110,12 @@ export default function createCssWebpackConfig({
|
|||||||
browserslist
|
browserslist
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!isDev) {
|
||||||
webpackConfig.plugin('extra-css')
|
webpackConfig.plugin('extra-css')
|
||||||
.use(require.resolve('mini-css-extract-plugin'), [{
|
.use(require.resolve('mini-css-extract-plugin'), [{
|
||||||
filename: isDev ? '[name].css' : '[name].[contenthash:8].css',
|
filename: '[name].[contenthash:8].css',
|
||||||
chunkFilename: isDev ? '[id].css' : '[id].[contenthash:8].css'
|
chunkFilename: '[id].[contenthash:8].css'
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
if (!isDev) {
|
|
||||||
webpackConfig.optimization
|
webpackConfig.optimization
|
||||||
.minimizer('css')
|
.minimizer('css')
|
||||||
.use(require.resolve('css-minimizer-webpack-plugin'), [{}]);
|
.use(require.resolve('css-minimizer-webpack-plugin'), [{}]);
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
home
|
home
|
||||||
|
<FButton class="m-2">Button</FButton>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<config>
|
|
||||||
{
|
|
||||||
"name": "index",
|
|
||||||
"title": "$home"
|
|
||||||
}
|
|
||||||
</config>
|
|
||||||
<script>
|
<script>
|
||||||
|
import { FButton } from '@fesjs/fes-design';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
FButton
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
return {
|
return {
|
||||||
@ -24,3 +23,10 @@ export default {
|
|||||||
.page {
|
.page {
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<config>
|
||||||
|
{
|
||||||
|
"name": "index",
|
||||||
|
"title": "$home"
|
||||||
|
}
|
||||||
|
</config>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user