-
Notifications
You must be signed in to change notification settings - Fork 0
/
craco.config.js
50 lines (47 loc) · 1.73 KB
/
craco.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const path = require("path");
const CracoLessPlugin = require('craco-less');
const AntDesignThemePlugin = require('antd-theme-webpack-plugin');
const CompressionPlugin = require("compression-webpack-plugin"); // 压缩文件
const options = {
stylesDir: path.join(__dirname, './src/styles'),
antDir: path.join(__dirname, './node_modules/antd'),
mainLessFile: path.join(__dirname, './src/index.less'),
varFile: path.join(__dirname, './src/styles/variables.less'),
themeVariables: ['@primary-color'],
indexFileName: 'index.html',
generateOnce: false,
}
module.exports = {
webpack: {
plugins: [
new AntDesignThemePlugin(options),
new CompressionPlugin({
filename: '[path].gz[query]', // 目标资源名称。[file] 会被替换成原资源。[path] 会被替换成原资源路径,[query] 替换成原查询字符串
algorithm: 'gzip', // 算法
test: new RegExp('\\.(js|css)$'), // 压缩 js 与 css
threshold: 1024, // 只处理比这个值大的资源。按字节计算
minRatio: 0.8 // 只有压缩率比这个值小的资源才会被处理
}),
],
alias: {
"@": path.resolve(__dirname, 'src')
// 此处是一个示例,实际可根据各自需求配置
},
},
devServer: {
port: 3333
},
plugins: [{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
// modifyVars: {
// '@primary-color': '#005792'
// },
javascriptEnabled: true,
},
},
},
}],
};