31 lines
713 B
TypeScript
31 lines
713 B
TypeScript
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
|
||
}
|
||
}
|
||
}
|
||
]
|
||
}
|