fix: generate settings.min.js for production sites without SCRIPT_DEBUG
WordPress loads settings.min.js instead of settings.js when SCRIPT_DEBUG is false (the default on production sites). The old settings.min.js from the original plugin was still present and caused a crash because it referenced licence.is_set which could be undefined. - Add @rollup/plugin-terser to build dependencies - Update rollup.config.mjs to output both settings.js (dev) and settings.min.js (prod, minified) from the same source - Rebuild both outputs with all licence-removal changes included Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import svelte from 'rollup-plugin-svelte';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import css from 'rollup-plugin-css-only';
|
||||
import terser from '@rollup/plugin-terser';
|
||||
|
||||
// const production = !process.env.ROLLUP_WATCH;
|
||||
const production = false; // Keep runtime checks for the moment.
|
||||
@@ -10,37 +11,59 @@ const production = false; // Keep runtime checks for the moment.
|
||||
// The base plugin's compiled output (assets/js/settings.js) is committed directly.
|
||||
// This config only builds the Pro-specific entry point.
|
||||
|
||||
export default [{
|
||||
input: 'ui/pro/Settings.svelte',
|
||||
output: {
|
||||
sourcemap: true,
|
||||
format: 'umd',
|
||||
name: 'AS3CFPro_Settings',
|
||||
file: 'assets/js/pro/settings.js'
|
||||
},
|
||||
plugins: [
|
||||
svelte( {
|
||||
compilerOptions: {
|
||||
// enable run-time checks when not in production
|
||||
dev: !production
|
||||
}
|
||||
} ),
|
||||
// we'll extract any component CSS out into
|
||||
// a separate file - better for performance
|
||||
css( { output: 'settings.css' } ),
|
||||
const sharedPlugins = [
|
||||
svelte( {
|
||||
compilerOptions: {
|
||||
// enable run-time checks when not in production
|
||||
dev: !production
|
||||
}
|
||||
} ),
|
||||
// we'll extract any component CSS out into
|
||||
// a separate file - better for performance
|
||||
css( { output: 'settings.css' } ),
|
||||
|
||||
// If you have external dependencies installed from
|
||||
// npm, you'll most likely need these plugins. In
|
||||
// some cases you'll need additional configuration -
|
||||
// consult the documentation for details:
|
||||
// https://github.com/rollup/plugins/tree/master/packages/commonjs
|
||||
resolve( {
|
||||
browser: true,
|
||||
dedupe: ['svelte']
|
||||
} ),
|
||||
commonjs()
|
||||
],
|
||||
watch: {
|
||||
clearScreen: false
|
||||
// If you have external dependencies installed from
|
||||
// npm, you'll most likely need these plugins. In
|
||||
// some cases you'll need additional configuration -
|
||||
// consult the documentation for details:
|
||||
// https://github.com/rollup/plugins/tree/master/packages/commonjs
|
||||
resolve( {
|
||||
browser: true,
|
||||
dedupe: ['svelte']
|
||||
} ),
|
||||
commonjs()
|
||||
];
|
||||
|
||||
export default [
|
||||
// Unminified build (loaded when SCRIPT_DEBUG = true)
|
||||
{
|
||||
input: 'ui/pro/Settings.svelte',
|
||||
output: {
|
||||
sourcemap: true,
|
||||
format: 'umd',
|
||||
name: 'AS3CFPro_Settings',
|
||||
file: 'assets/js/pro/settings.js'
|
||||
},
|
||||
plugins: sharedPlugins,
|
||||
watch: {
|
||||
clearScreen: false
|
||||
}
|
||||
},
|
||||
// Minified build (loaded when SCRIPT_DEBUG = false, i.e. production)
|
||||
{
|
||||
input: 'ui/pro/Settings.svelte',
|
||||
output: {
|
||||
sourcemap: true,
|
||||
format: 'umd',
|
||||
name: 'AS3CFPro_Settings',
|
||||
file: 'assets/js/pro/settings.min.js'
|
||||
},
|
||||
plugins: [
|
||||
...sharedPlugins,
|
||||
terser()
|
||||
],
|
||||
watch: {
|
||||
clearScreen: false
|
||||
}
|
||||
}
|
||||
}];
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user