115 lines
2.3 KiB
JavaScript
115 lines
2.3 KiB
JavaScript
import { terser } from 'rollup-plugin-terser';
|
|
import resolve from '@rollup/plugin-node-resolve';
|
|
import commonjs from '@rollup/plugin-commonjs';
|
|
|
|
const production = !process.env.ROLLUP_WATCH;
|
|
|
|
// Common plugins
|
|
const createPlugins = () => [
|
|
resolve({
|
|
browser: true,
|
|
preferBuiltins: false,
|
|
mainFields: ['browser', 'module', 'main']
|
|
}),
|
|
commonjs({
|
|
include: /node_modules/,
|
|
transformMixedEsModules: true
|
|
}),
|
|
production && terser({
|
|
compress: {
|
|
passes: 2,
|
|
pure_getters: true,
|
|
drop_debugger: true
|
|
},
|
|
mangle: {
|
|
properties: {
|
|
regex: /^_/
|
|
}
|
|
},
|
|
format: {
|
|
comments: false
|
|
}
|
|
})
|
|
].filter(Boolean);
|
|
|
|
export default [
|
|
// Main app bundle - without code splitting
|
|
{
|
|
input: 'src/js/app.js',
|
|
output: {
|
|
file: 'static/js/app.modern.min.js',
|
|
format: 'es',
|
|
sourcemap: true,
|
|
compact: true
|
|
},
|
|
plugins: createPlugins(),
|
|
external: ['./utils.js'],
|
|
treeshake: {
|
|
moduleSideEffects: false,
|
|
propertyReadSideEffects: false
|
|
}
|
|
},
|
|
|
|
// Utility library
|
|
{
|
|
input: 'src/js/utils.js',
|
|
output: {
|
|
file: 'static/js/utils.modern.min.js',
|
|
format: 'es',
|
|
sourcemap: true,
|
|
compact: true
|
|
},
|
|
plugins: createPlugins(),
|
|
treeshake: {
|
|
moduleSideEffects: false
|
|
}
|
|
},
|
|
|
|
// Video initialization bundle
|
|
{
|
|
input: 'src/js/video-init.js',
|
|
output: {
|
|
file: 'static/js/video-init.modern.min.js',
|
|
format: 'es',
|
|
sourcemap: true,
|
|
compact: true
|
|
},
|
|
plugins: createPlugins(),
|
|
external: ['./utils.js'],
|
|
treeshake: {
|
|
moduleSideEffects: false
|
|
}
|
|
},
|
|
|
|
// Skip to content bundle
|
|
{
|
|
input: 'src/js/skip-to-content.js',
|
|
output: {
|
|
file: 'static/js/skip-to-content.modern.min.js',
|
|
format: 'es',
|
|
sourcemap: true,
|
|
compact: true
|
|
},
|
|
plugins: createPlugins(),
|
|
external: ['./utils.js'],
|
|
treeshake: {
|
|
moduleSideEffects: false
|
|
}
|
|
},
|
|
|
|
// Material design wrapper
|
|
{
|
|
input: 'src/js/material.modern.js',
|
|
output: {
|
|
file: 'static/js/material.modern.min.js',
|
|
format: 'es',
|
|
sourcemap: true,
|
|
compact: true
|
|
},
|
|
plugins: createPlugins(),
|
|
external: ['./utils.js'],
|
|
treeshake: {
|
|
moduleSideEffects: false
|
|
}
|
|
}
|
|
];
|