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.
This commit is contained in:
Sped0n
2023-11-01 23:13:05 +08:00
parent b91a67e0da
commit 09583bfc0a

29
rollup.config.mjs Normal file
View File

@@ -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
}
})
]
}