replace to 1st place in plugins

This commit is contained in:
Albert
2025-12-06 07:37:50 +05:00
parent 09d2e0ae99
commit face0e67e9
3 changed files with 22 additions and 21 deletions
+15 -14
View File
@@ -23,7 +23,21 @@ module.exports = {
// plugin set up and used to ensure as consist set of tests
// as possible.
getDefaultPlugins: (buildType, buildFormat = 'iife', es5 = false) => {
const plugins = [nodeResolve()];
const plugins = [];
// This is what the build should be
const replaceOptions = {
preventAssignment: true,
WORKBOX_CDN_ROOT_URL: getVersionsCDNUrl(),
};
if (buildType) {
replaceOptions['process.env.NODE_ENV'] = JSON.stringify(buildType);
}
// Replace allows us to input NODE_ENV and strip code accordingly
plugins.push(replace(replaceOptions));
plugins.push(nodeResolve());
const babelConfig = {
babelHelpers: 'bundled',
@@ -81,19 +95,6 @@ module.exports = {
plugins.push(terserPlugin(terserOptions));
}
// This is what the build should be
const replaceOptions = {
preventAssignment: true,
WORKBOX_CDN_ROOT_URL: getVersionsCDNUrl(),
};
if (buildType) {
replaceOptions['process.env.NODE_ENV'] = JSON.stringify(buildType);
}
// Replace allows us to input NODE_ENV and strip code accordingly
plugins.push(replace(replaceOptions));
return plugins;
},
};
+6 -6
View File
@@ -39,6 +39,12 @@ async function handler(req, res) {
const bundle = await rollup({
input: `./test/${packageName}/sw/` + testFilter,
plugins: [
replace({
'preventAssignment': true,
'process.env.NODE_ENV': JSON.stringify(env),
'SW_NAMESPACES': JSON.stringify(SW_NAMESPACES),
'WORKBOX_CDN_ROOT_URL': '/__WORKBOX/buildFile',
}),
multiEntry(),
nodeResolve({
moduleDirectories: ['packages', 'node_modules'],
@@ -48,12 +54,6 @@ async function handler(req, res) {
commonjs({
exclude: '*.mjs',
}),
replace({
'preventAssignment': true,
'process.env.NODE_ENV': JSON.stringify(env),
'SW_NAMESPACES': JSON.stringify(SW_NAMESPACES),
'WORKBOX_CDN_ROOT_URL': '/__WORKBOX/buildFile',
}),
],
// Fail in the case of warning, so rebuilds work.
onwarn({loc, message}) {
+1 -1
View File
@@ -43,12 +43,12 @@ export async function bundle({
await writeFile(temporaryFile, unbundledCode);
const plugins = [
nodeResolve(),
replace({
// See https://github.com/GoogleChrome/workbox/issues/2769
'preventAssignment': true,
'process.env.NODE_ENV': JSON.stringify(mode),
}),
nodeResolve(),
babel({
babelHelpers: 'bundled',
// Disable the logic that checks for local Babel config files: