-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcraco.config.ts
88 lines (84 loc) · 2.53 KB
/
craco.config.ts
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
import path from "path";
import CracoLessPlugin from "craco-less";
// import { API_URL } from "./src/config";
import NodePolyfillPlugin from "node-polyfill-webpack-plugin";
module.exports = {
webpack: {
alias: {
"@": path.resolve(__dirname, "src"),
},
configure: webpackConfig => {
const scopePluginIndex =
webpackConfig.resolve.plugins.findIndex(
({constructor}) =>
constructor &&
constructor.name === 'ModuleScopePlugin',
);
webpackConfig.resolve.plugins.splice(scopePluginIndex, 1);
webpackConfig.resolve.fallback = {
// fs: require.resolve("fs"),
fs: false,
path: require.resolve("path-browserify"),
crypto: require.resolve("crypto-browserify"),
assert: require.resolve("assert/"),
http: require.resolve("stream-http"),
https: require.resolve("https-browserify"),
url: require.resolve("url/"),
os: require.resolve("os-browserify/browser"),
buffer: require.resolve("buffer"),
stream: require.resolve("stream-browserify"),
};
return webpackConfig;
},
plugins: [
//If the Transform of stream does not work, be sure to unload to the stream package
// `yarn remove stream`
//https://github.com/Richienb/node-polyfill-webpack-plugin
new NodePolyfillPlugin({
excludeAliases: ["console"],
}),
//for debug
/* new TerserPlugin({
parallel: true,
extractComments: false, //remove comment step 1
terserOptions: {
sourceMap: false, // Must be set to true if using source-maps in production
ecma: undefined,
parse: {},
format: {
comments: false, //remove comment step 2
},
compress: {
warnings: false,
drop_console: process.env.NODE_ENV !== "development", // remove all contents of the console from the production environment
drop_debugger: process.env.NODE_ENV !== "development", // Remove breakpoints
},
},
}),*/
],
devServer: {
historyApiFallback: true,
host: "127.0.0.1",
port: 8090,
stats: "errors-only",
overlay: true,
hot: true,
headers: {
"Access-Control-Allow-Origin": "*",
},
},
},
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: {},
javascriptEnabled: true,
},
},
},
},
],
};