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-02-13 18:35:32 +03:00
|
|
|
function build(filename) {
|
2023-03-13 15:20:59 +03:00
|
|
|
return {
|
2024-02-13 18:35:32 +03:00
|
|
|
input: [`${SRC_DEFAULT}/${filename}.js`],
|
2023-03-13 15:20:59 +03:00
|
|
|
output: {
|
2024-02-13 18:35:32 +03:00
|
|
|
file: `${DIST_DEFAULT}/${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-02-13 18:35:32 +03:00
|
|
|
include: `${SRC_DEFAULT}/**`
|
2023-03-30 23:55:09 +03:00
|
|
|
},
|
2023-03-13 15:20:59 +03:00
|
|
|
plugins: [
|
|
|
|
babel({
|
|
|
|
babelHelpers: 'bundled',
|
|
|
|
presets: ['@babel/env'],
|
2024-02-25 15:30:21 +03:00
|
|
|
plugins: ['@babel/plugin-transform-class-properties']
|
2023-03-13 15:20:59 +03:00
|
|
|
}),
|
|
|
|
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-02-13 18:35:32 +03:00
|
|
|
build('misc')
|
2023-03-13 15:20:59 +03:00
|
|
|
];
|