mirror of
https://github.com/re-rxjs/react-rxjs.git
synced 2025-12-08 18:01:51 +00:00
34 lines
759 B
JavaScript
34 lines
759 B
JavaScript
const path = require("path")
|
|
|
|
const isProd = process.argv[2] === "--prod"
|
|
|
|
const fixCjsPlugin = {
|
|
name: "fixCJS",
|
|
setup(build) {
|
|
build.onResolve({ filter: /useSyncExternalStore/ }, (args) => {
|
|
return {
|
|
path: path.join(args.resolveDir, args.path + "Cjs.ts"),
|
|
}
|
|
})
|
|
},
|
|
}
|
|
|
|
require("esbuild")
|
|
.build({
|
|
entryPoints: ["src/index.tsx"],
|
|
bundle: true,
|
|
outfile: isProd
|
|
? "./dist/core.cjs.production.min.js"
|
|
: "./dist/core.cjs.development.js",
|
|
target: "es2015",
|
|
minify: isProd,
|
|
external: ["react", "rxjs", "@rx-state/core", "use-sync-external-store"],
|
|
format: "cjs",
|
|
sourcemap: true,
|
|
plugins: [fixCjsPlugin],
|
|
})
|
|
.catch((error) => {
|
|
console.error(error)
|
|
process.exit(1)
|
|
})
|