Skip to content

Commit

Permalink
build: compress and strip comments in production
Browse files Browse the repository at this point in the history
  • Loading branch information
darlal committed Sep 7, 2024
1 parent 50aa2b9 commit 16d17c4
Show file tree
Hide file tree
Showing 4 changed files with 229 additions and 14 deletions.
217 changes: 205 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"devDependencies": {
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@types/chance": "^1.1.6",
"@types/jest": "^29.5.12",
Expand Down
17 changes: 15 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
import typescript from '@rollup/plugin-typescript';
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
import { nodeResolve } from '@rollup/plugin-node-resolve';

const isProd = process.env.BUILD === 'production';
const tsconfig = isProd ? './tsconfig.prod.json' : './tsconfig.json'

export default {
input: 'src/main.ts',
treeshake: false,
output: {
dir: 'dist/darlal-switcher-plus',
sourcemap: 'inline',
sourcemap: isProd ? false : 'inline',
sourcemapExcludeSources: isProd,
format: 'cjs',
exports: 'default',
},
external: ['obsidian', 'electron'],
plugins: [typescript(), nodeResolve(), commonjs()],
plugins: [
typescript({ tsconfig }),
nodeResolve(),
commonjs(),
isProd && terser({
format: {
comments: false
},
sourceMap: false,
compress: true
})
],
};
8 changes: 8 additions & 0 deletions tsconfig.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"inlineSourceMap": false,
"sourceMap": false,
"inlineSources": false
}
}

0 comments on commit 16d17c4

Please sign in to comment.