-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcraco.config.js
More file actions
89 lines (83 loc) · 2.4 KB
/
Copy pathcraco.config.js
File metadata and controls
89 lines (83 loc) · 2.4 KB
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
const CracoLessPlugin = require('craco-less');
const webpack = require("webpack");
const fs = require("fs");
const path = require('path');
const keyPath = path.resolve(__dirname, './demo.locker.io-key.pem');
const certPath = path.resolve(__dirname, './demo.locker.io.pem');
let httpsConfig = {};
if (fs.existsSync(keyPath) && fs.existsSync(certPath)) {
httpsConfig = {
key: fs.readFileSync(keyPath),
cert: fs.readFileSync(certPath),
};
}
module.exports = {
babel: {
plugins: [
['import', { libraryName: '@lockerpm/design', libraryDirectory: 'es', style: true }],
],
},
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: {
'@primary-color': '#42a5f5',
'@text-selection-bg': '#1890ff',
},
javascriptEnabled: true
},
},
},
},
],
typescript: {
enableTypeChecking: false,
},
webpack: {
configure: (config) => {
// Skip parsing papaparse.min.js to avoid Babel stack overflow
config.module.noParse = /node_modules\/papaparse\/papaparse\.min\.js/;
// Exclude papaparse from babel-loader to prevent stack overflow on large minified file
config.module.rules.forEach((rule) => {
if (rule.oneOf) {
rule.oneOf.forEach((oneOfRule) => {
if (
oneOfRule.loader &&
oneOfRule.loader.includes('babel-loader')
) {
if (!oneOfRule.exclude) {
oneOfRule.exclude = [];
}
if (!Array.isArray(oneOfRule.exclude)) {
oneOfRule.exclude = [oneOfRule.exclude];
}
oneOfRule.exclude.push(/node_modules\/papaparse/);
}
});
}
});
config.resolve.fallback = {
...config.resolve.fallback,
'process/browser': require.resolve("process/browser"),
process: require.resolve("process/browser"),
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("stream-browserify"),
buffer: require.resolve("buffer"),
vm: false,
};
config.plugins.push(
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
process: "process/browser",
})
);
return config;
},
},
devServer: {
https: httpsConfig
}
}