-
Notifications
You must be signed in to change notification settings - Fork 73
/
craco.config.js
100 lines (95 loc) · 2.68 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
const CracoLessPlugin = require("craco-less")
const webpack = require("webpack")
const path = require("path")
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
// const SentryWebpackPlugin = require("@sentry/webpack-plugin")
require("./scripts/download-blog-posts.data.json.js")
module.exports = {
babel: {
plugins: ["@emotion/babel-plugin"],
},
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: {},
javascriptEnabled: true,
},
},
},
},
],
// local proxy
devServer: {
proxy: {
// "/bridgehistory/api": {
// target: "http://localhost:4000",
// pathRewrite: { "^/bridgehistory/api": "/api" },
// },
// "/rollupscan/api": {
// target: "http://10.0.3.119:8560",
// pathRewrite: { "^/rollupscan/api": "/api" },
// },
},
},
webpack: {
alias: {
"@": path.resolve(__dirname, "src"),
assert: "assert",
buffer: "buffer",
crypto: "crypto-browserify",
http: "stream-http",
https: "https-browserify",
os: "os-browserify/browser",
process: "process/browser",
stream: "stream-browserify",
util: "util",
},
experiments: {
asyncWebAssembly: true,
},
plugins: [
new webpack.ProvidePlugin({
process: "process/browser",
Buffer: ["buffer", "Buffer"],
}),
],
configure: function (webpackConfig, { env }) {
webpackConfig.ignoreWarnings = [
function ignoreSourcemapsloaderWarnings(warning) {
return (
warning.module && warning.module.resource.includes("node_modules") && warning.details && warning.details.includes("source-map-loader")
)
},
]
webpackConfig.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: "javascript/auto",
resolve: {
fullySpecified: false,
},
})
webpackConfig.module.rules.push({
test: /\.m?js$/,
include: /node_modules/,
type: "javascript/auto",
resolve: {
fullySpecified: false,
},
})
if (env === "production" && process.env.CI) {
// const sentryPlugin = new SentryWebpackPlugin({
// include: "./build",
// release: process.env.REACT_APP_VERSION,
// })
// webpackConfig.plugins.push(sentryPlugin)
const instanceOfMiniCssExtractPlugin = webpackConfig.plugins.find(plugin => plugin instanceof MiniCssExtractPlugin)
instanceOfMiniCssExtractPlugin.options.ignoreOrder = true
}
return webpackConfig
},
},
}