2023-03-13 15:20:59 +03:00
|
|
|
import babel from '@rollup/plugin-babel';
|
|
|
|
import terser from '@rollup/plugin-terser';
|
|
|
|
import license from 'rollup-plugin-license';
|
|
|
|
import path from 'path';
|
|
|
|
|
2024-01-27 21:22:33 +03:00
|
|
|
const SRC_DEFAULT = '_javascript';
|
|
|
|
const DIST_DEFAULT = 'assets/js/dist';
|
2023-03-13 15:20:59 +03:00
|
|
|
const isProd = process.env.NODE_ENV === 'production';
|
|
|
|
|
2024-01-27 21:22:33 +03:00
|
|
|
function build(filename, opts) {
|
|
|
|
let src = SRC_DEFAULT;
|
|
|
|
let dist = DIST_DEFAULT;
|
|
|
|
|
|
|
|
if (typeof opts !== 'undefined') {
|
|
|
|
src = opts.src || src;
|
|
|
|
dist = opts.dist || dist;
|
|
|
|
}
|
|
|
|
|
2023-03-13 15:20:59 +03:00
|
|
|
return {
|
2024-01-27 21:22:33 +03:00
|
|
|
input: [`${src}/${filename}.js`],
|
2023-03-13 15:20:59 +03:00
|
|
|
output: {
|
2024-01-27 21:22:33 +03:00
|
|
|
file: `${dist}/${filename}.min.js`,
|
2023-03-13 15:20:59 +03:00
|
|
|
format: 'iife',
|
|
|
|
name: 'Chirpy',
|
|
|
|
sourcemap: !isProd
|
|
|
|
},
|
2023-03-30 23:55:09 +03:00
|
|
|
watch: {
|
2024-01-27 21:22:33 +03:00
|
|
|
include: `${src}/**`
|
2023-03-30 23:55:09 +03:00
|
|
|
},
|
2023-03-13 15:20:59 +03:00
|
|
|
plugins: [
|
|
|
|
babel({
|
|
|
|
babelHelpers: 'bundled',
|
|
|
|
presets: ['@babel/env'],
|
|
|
|
plugins: ['@babel/plugin-proposal-class-properties']
|
|
|
|
}),
|
|
|
|
license({
|
|
|
|
banner: {
|
|
|
|
commentStyle: 'ignored',
|
2024-01-27 21:22:33 +03:00
|
|
|
content: { file: path.join(__dirname, SRC_DEFAULT, '_copyright') }
|
2023-03-13 15:20:59 +03:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
isProd && terser()
|
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default [
|
|
|
|
build('commons'),
|
2023-03-18 01:28:44 +03:00
|
|
|
build('home'),
|
2023-03-13 15:20:59 +03:00
|
|
|
build('categories'),
|
|
|
|
build('page'),
|
|
|
|
build('post'),
|
2024-01-27 21:22:33 +03:00
|
|
|
build('misc'),
|
|
|
|
build('app', { src: `${SRC_DEFAULT}/pwa` }),
|
|
|
|
build('sw', { src: `${SRC_DEFAULT}/pwa`, dist: '.' })
|
2023-03-13 15:20:59 +03:00
|
|
|
];
|