mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-12-04 23:43:51 +03:00
4164b6279e
* d3tooltip * map2tree * d3-state-visualizer * react-base16-styling * react-dock * Cleanup * Update * react-json-tree * redux-devtools * redux-devtools-app * redux-devtools-app-core * redux-devtools-cli * Fix * redux-devtools-dock-monitor * redux-devtools-extension * redux-devtools-inspector-monitor * redux-devtools-inspector-monitor-test-tab * redux-devtools-inspector-monitor-trace-tab * redux-devtools-instrument * Simplify * redux-devtools-log-monitor * redux-devtools-remote * redux-devtools-rtk-query-monitor * redux-devtools-serialize * redux-devtools-slider-monitor * redux-devtools-utils * Format
68 lines
1.5 KiB
JavaScript
68 lines
1.5 KiB
JavaScript
import * as esbuild from 'esbuild';
|
|
|
|
const args = process.argv.slice(2);
|
|
const prod = !args.includes('--dev');
|
|
|
|
await esbuild.build({
|
|
bundle: true,
|
|
logLevel: 'info',
|
|
format: 'iife',
|
|
globalName: 'ReduxDevToolsApp',
|
|
outfile: prod ? 'umd/redux-devtools-app.min.js' : 'umd/redux-devtools-app.js',
|
|
minify: prod,
|
|
sourcemap: true,
|
|
define: {
|
|
'process.env.NODE_ENV': prod ? '"production"' : '"development"',
|
|
},
|
|
entryPoints: ['src/index.tsx'],
|
|
loader: {
|
|
'.woff2': 'dataurl',
|
|
},
|
|
plugins: [
|
|
importAsGlobals({
|
|
react: 'React',
|
|
'react-dom': 'ReactDOM',
|
|
}),
|
|
],
|
|
});
|
|
|
|
// https://github.com/evanw/esbuild/issues/337#issuecomment-954633403
|
|
function importAsGlobals(mapping) {
|
|
// https://stackoverflow.com/a/3561711/153718
|
|
const escRe = (s) => s.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
const filter = new RegExp(
|
|
Object.keys(mapping)
|
|
.map((mod) => `^${escRe(mod)}$`)
|
|
.join('|'),
|
|
);
|
|
|
|
return {
|
|
name: 'global-imports',
|
|
setup(build) {
|
|
build.onResolve({ filter }, (args) => {
|
|
if (!mapping[args.path]) {
|
|
throw new Error('Unknown global: ' + args.path);
|
|
}
|
|
return {
|
|
path: args.path,
|
|
namespace: 'external-global',
|
|
};
|
|
});
|
|
|
|
build.onLoad(
|
|
{
|
|
filter,
|
|
namespace: 'external-global',
|
|
},
|
|
async (args) => {
|
|
const global = mapping[args.path];
|
|
return {
|
|
contents: `module.exports = ${global};`,
|
|
loader: 'js',
|
|
};
|
|
},
|
|
);
|
|
},
|
|
};
|
|
}
|