Commit 8743910d authored by Robert Knight's avatar Robert Knight

Use @rollup/plugin-virtual to exclude modules in production

Make conditional exclusion of modules work the same way in the app
bundle as in the tests bundle.
parent e40f8438
......@@ -5,18 +5,19 @@ import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import { string } from 'rollup-plugin-string';
import { terser } from 'rollup-plugin-terser';
import virtual from '@rollup/plugin-virtual';
const isProd = process.env.NODE_ENV === 'production';
const prodPlugins = [];
const prodAliases = [];
if (isProd) {
prodPlugins.push(terser());
// Exclude 'preact/debug' from production builds.
prodAliases.push({
find: 'preact/debug',
replacement: 'preact',
});
// Eliminate debug-only imports.
prodPlugins.push(
virtual({
'preact/debug': '',
})
);
}
function bundleConfig(name, entryFile) {
......@@ -44,7 +45,6 @@ function bundleConfig(name, entryFile) {
find: 'preact/compat/jsx-dev-runtime',
replacement: 'preact/jsx-dev-runtime',
},
...prodAliases,
],
}),
replace({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment