monorepo-microservice-rbac/apps/aorta/scripts/loaders/style.loader.ts

31 lines
713 B
TypeScript
Raw Permalink Normal View History

2023-08-27 14:37:59 +08:00
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const isDev = process.env.NODE_ENV === 'development' // 是否是开发模式
const styleLoadersArray = [
isDev ? 'style-loader' : MiniCssExtractPlugin.loader, // 开发环境使用style-looader,打包模式抽离css
{
loader: 'css-loader'
}
]
export const cssLoader = {
test: /.css$/, //匹配 css 文件
use: styleLoadersArray
}
export const lessLoader = {
test: /\.less$/,
use: [
...styleLoadersArray,
{
loader: 'less-loader',
options: {
lessOptions: {
// 如果要在less中写类型js的语法需要加这一个配置
javascriptEnabled: true
}
}
}
]
}