Skip to content

Commit 10ab7e6

Browse files
committed
optimize export on prod env only
1 parent a98bf18 commit 10ab7e6

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

craco.config.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
const path = require('path')
22

3+
function isDevelopmentEnv() {
4+
return process.env.NODE_ENV === 'development'
5+
}
6+
37
module.exports = {
48
webpack: {
59
alias: {
@@ -10,10 +14,10 @@ module.exports = {
1014
filename: 'static/js/[name].js',
1115
},
1216
optimization: {
13-
runtimeChunk: false,
17+
runtimeChunk: isDevelopmentEnv(),
1418
splitChunks: {
1519
chunks(chunk) {
16-
return false
20+
return isDevelopmentEnv()
1721
},
1822
},
1923
},
@@ -23,6 +27,10 @@ module.exports = {
2327
{
2428
plugin: {
2529
overrideWebpackConfig: ({ webpackConfig }) => {
30+
if (isDevelopmentEnv()) {
31+
return webpackConfig
32+
}
33+
2634
let mcep
2735
webpackConfig.plugins.some((p) => {
2836
if (p.constructor.name === 'MiniCssExtractPlugin') {

0 commit comments

Comments
 (0)