This repository has been archived by the owner on Oct 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
craco.config.js
121 lines (115 loc) · 3.58 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// APP CONFIG
const APP_NAME = "kalendly";
const isEnvProduction = process.env.NODE_ENV === "production";
const ASSET_PATH = isEnvProduction ? `/apps/${APP_NAME}/` : "/";
// APP CONFIG
const path = require("path");
// DUMP and check the WEBPACK config
const { WebpackConfigDumpPlugin } = require("webpack-config-dump-plugin");
const tailwindcss_plugin = require("tailwindcss");
const autoprefixer_plugin = require("autoprefixer");
// COMMON CONFIG ########################################################
// antd - replace moment with dayjs - https://ant.design/docs/react/replace-moment
const AntdDayjsWebpackPlugin = require("antd-dayjs-webpack-plugin");
const CracoLessPlugin = require("craco-less");
const { getThemeVariables } = require("antd/dist/theme");
module.exports = {
style: {
modules: {
localIdentName: `${APP_NAME}-[local]-[hash:base64:5]`,
},
postcss: {
plugins: [tailwindcss_plugin, autoprefixer_plugin],
},
},
babel: {
plugins: [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-transform-react-jsx",
"@babel/plugin-proposal-class-properties",
[
"import",
{
libraryName: "antd",
libraryDirectory: "es",
style: true,
},
"antd",
],
[
"import",
{
libraryName: "@ant-design/icons",
libraryDirectory: "es/icons",
camel2DashComponentName: false,
},
"@ant-design/icons",
],
[
"import",
{
libraryName: "lodash",
libraryDirectory: "",
camel2DashComponentName: false, // default: true
},
"lodash",
],
[
"@babel/plugin-transform-react-jsx",
{
pragma: "h",
pragmaFrag: "Fragment",
},
"preact",
],
],
},
webpack: {
plugins: [
new WebpackConfigDumpPlugin({
depth: 8,
name: "debug.webpack.config.js",
}),
new AntdDayjsWebpackPlugin(),
],
configure: {
entry: {
main: "./src/index.js",
},
output: {
libraryTarget: "self",
filename: `[name].${APP_NAME}.js`,
path: path.resolve(__dirname, "build"),
crossOriginLoading: "anonymous",
publicPath: ASSET_PATH,
devtoolNamespace: `${APP_NAME}`,
globalObject: "self",
},
},
resolve: {
alias: {
react: "preact/compat",
"react-dom/test-utils": "preact/test-utils",
"react-dom": "preact/compat",
// Must be below test-utils
},
},
},
// craco config override
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: getThemeVariables({
dark: false, // Enable dark mode
compact: false,
}),
javascriptEnabled: true,
},
},
},
},
],
};