-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcraco.config.js
71 lines (64 loc) · 2.33 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const path = require('path')
const { addAfterLoader, removeLoaders, loaderByName, removePlugins, addPlugins, pluginByName } = require('@craco/craco')
const CracoLessPlugin = require('craco-less')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
module.exports = {
style: {
postcss: {
plugins: [require('tailwindcss'), require('autoprefixer')],
},
},
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: { '@primary-color': '#93C5FD' },
javascriptEnabled: true,
},
},
},
},
],
babel: {
plugins: [['import', { libraryName: 'antd', style: true }]],
},
webpack: {
configure: (webpackConfig, { env, paths }) => {
const publicPath = env === 'production' ? 'https://cloudr-f2e.github.io/monitor-demo/' : './'
if (env === 'production') {
const fileLoader = {
loader: require.resolve('file-loader'),
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
options: {
name: 'static/media/[name].[hash:8].[ext]',
publicPath,
},
}
removeLoaders(webpackConfig, loaderByName('file-loader'))
addAfterLoader(webpackConfig, loaderByName('babel-loader'), fileLoader)
removePlugins(webpackConfig, pluginByName('MiniCssExtractPlugin'))
addPlugins(webpackConfig, [
new MiniCssExtractPlugin({
filename: 'static/css/[name].[contenthash:8].css',
chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
ignoreOrder: true,
}),
])
}
return {
...webpackConfig,
output: {
...webpackConfig.output,
publicPath,
},
resolve: {
alias: {
src: path.resolve(__dirname, './src'),
},
},
}
},
},
}