Files
WPS3Media/rollup.config.mjs
Malin fed42c6769 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>
2026-03-03 14:28:40 +01:00

70 lines
1.8 KiB
JavaScript

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.
// Note: ui/lite/Settings.svelte belongs to the base plugin (not present in this Pro-only repo).
// The base plugin's compiled output (assets/js/settings.js) is committed directly.
// This config only builds the Pro-specific entry point.
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()
];
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
}
}
];