feat(build): add support for Create React App without eject (#7946)
Refs #7898 Refs #7944 Refs #7935 Refs #7910 Refs #7908 Refs #7902
This commit is contained in:
@@ -15,11 +15,14 @@ import { WebpackBundleSizeAnalyzerPlugin } from "webpack-bundle-size-analyzer"
|
|||||||
import nodeExternals from "webpack-node-externals"
|
import nodeExternals from "webpack-node-externals"
|
||||||
// import { StatsWriterPlugin } from "webpack-stats-plugin"
|
// import { StatsWriterPlugin } from "webpack-stats-plugin"
|
||||||
|
|
||||||
|
const minimize = true
|
||||||
|
const sourcemaps = true
|
||||||
|
|
||||||
const result = configBuilder(
|
const result = configBuilder(
|
||||||
{
|
{
|
||||||
minimize: true,
|
minimize,
|
||||||
mangle: true,
|
mangle: true,
|
||||||
sourcemaps: true,
|
sourcemaps,
|
||||||
includeDependencies: false,
|
includeDependencies: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -41,12 +44,28 @@ const result = configBuilder(
|
|||||||
module: true,
|
module: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
devtool: sourcemaps && minimize ? "source-map" : false,
|
||||||
externalsType: "module",
|
externalsType: "module",
|
||||||
externals: [
|
externals: [
|
||||||
{
|
{
|
||||||
esprima: "esprima",
|
esprima: "esprima",
|
||||||
},
|
},
|
||||||
nodeExternals({
|
nodeExternals({
|
||||||
|
allowlist: [
|
||||||
|
/object\/define-property/, // @babel/runtime-corejs3 import which makes fragment work with Jest
|
||||||
|
"deep-extend", // uses Buffer as global symbol
|
||||||
|
"randombytes", // uses require('safe-buffer')
|
||||||
|
"sha.js", // uses require('safe-buffer')
|
||||||
|
"xml", // uses require('stream')
|
||||||
|
/process\/browser/, // is injected via ProvidePlugin
|
||||||
|
/readable-stream/, // byproduct of buffer ProvidePlugin injection
|
||||||
|
"util-deprecate", // dependency of readable-stream
|
||||||
|
"inherits", // dependency of readable-stream
|
||||||
|
"events", // dependency of readable-stream
|
||||||
|
/safe-buffer/, // contained in resolve.alias
|
||||||
|
/string_decoder/, // byproduct of buffer ProvidePlugin injection
|
||||||
|
"buffer", // buffer is injected via ProvidePlugin
|
||||||
|
],
|
||||||
importType: (moduleName) => {
|
importType: (moduleName) => {
|
||||||
return `module ${moduleName}`
|
return `module ${moduleName}`
|
||||||
}})
|
}})
|
||||||
@@ -65,5 +84,4 @@ const result = configBuilder(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
export default result
|
export default result
|
||||||
|
|||||||
Reference in New Issue
Block a user