From 09583bfc0a19d1356b7e6fe0bc1f69830a473efb Mon Sep 17 00:00:00 2001 From: Sped0n Date: Wed, 1 Nov 2023 23:13:05 +0800 Subject: [PATCH] chore(rollup.config.mjs): add rollup configuration file to bundle and transpile TypeScript code The rollup.config.mjs file is added to the project. This file contains the configuration for Rollup, a module bundler, to bundle and transpile TypeScript code. The configuration includes the input file path, the output directory, the output format, and other options such as source maps and code minification. The resolve plugin is used to resolve module imports, the typescript plugin is used to transpile TypeScript code, and the terser plugin is used to minify the code in production builds. The configuration also checks the BUILD environment variable to conditionally enable code minification in production builds. --- rollup.config.mjs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 rollup.config.mjs diff --git a/rollup.config.mjs b/rollup.config.mjs new file mode 100644 index 0000000..ec5f111 --- /dev/null +++ b/rollup.config.mjs @@ -0,0 +1,29 @@ +import resolve from '@rollup/plugin-node-resolve' +import terser from '@rollup/plugin-terser' +import typescript from '@rollup/plugin-typescript' + +export default { + input: './assets/ts/main.ts', + sourceMap: 'inline', + output: { + dir: './static/js', + format: 'es', + chunkFileNames: '[hash:6].js', + compact: true + }, + plugins: [ + resolve({ + moduleDirectories: ['node_modules'] + }), + typescript({ tsconfig: './tsconfig.json' }), + process.env.BUILD === 'production' && + terser({ + compress: { + passes: 3 + }, + output: { + comments: false + } + }) + ] +}