Skip to content

Commit

Permalink
chore: add rollup terser option(drop_console) jd-opensource#1363
Browse files Browse the repository at this point in the history
  • Loading branch information
richard1015 committed Jun 15, 2022
1 parent 19ca767 commit c814f01
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 38 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"markdown-it-container": "^3.0.0",
"prettier": "^2.0.0",
"remark-codesandbox": "^0.10.1",
"rollup-plugin-terser": "^7.0.2",
"standard-version": "^9.3.0",
"swiper": "6.5.1",
"transliteration": "^2.2.0",
Expand Down
17 changes: 10 additions & 7 deletions vite.config.build.disperse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import vue from '@vitejs/plugin-vue';
import path from 'path';
import config from './package.json';
import configPkg from './src/config.json';
import { terser } from 'rollup-plugin-terser';

const banner = `/*!
* ${config.name} v${config.version} ${new Date()}
Expand Down Expand Up @@ -60,12 +61,6 @@ declare module 'vue' {
],
build: {
minify: false,
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
},
lib: {
entry: '',
name: 'index',
Expand All @@ -82,7 +77,15 @@ declare module 'vue' {
'@/packages/locale': '../locale/lang'
},
dir: path.resolve(__dirname, './dist/packages/_es'),
entryFileNames: '[name].js'
entryFileNames: '[name].js',
plugins: [
terser({
compress: {
drop_console: true,
drop_debugger: true
}
})
]
}
},
emptyOutDir: false
Expand Down
17 changes: 10 additions & 7 deletions vite.config.build.locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ let input = {
input[file] = `./src/packages/locale/lang/${file}`;
});
import fs from 'fs-extra';
import { terser } from 'rollup-plugin-terser';
// 构建index.scss 兼容插件市场按需加载插件
fs.outputFile(path.resolve(__dirname, './dist/packages/locale/index.scss'), ' ', 'utf8', (error) => {});
fs.outputFile(path.resolve(__dirname, './dist/packages/locale/lang/index.scss'), ' ', 'utf8', (error) => {});
Expand All @@ -34,12 +35,6 @@ export default defineConfig({
],
build: {
minify: true,
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
},
lib: {
entry: '',
name: 'index',
Expand All @@ -53,7 +48,15 @@ export default defineConfig({
output: {
banner,
dir: path.resolve(__dirname, './dist/packages/locale/lang'),
entryFileNames: '[name].js'
entryFileNames: '[name].js',
plugins: [
terser({
compress: {
drop_console: true,
drop_debugger: true
}
})
]
}
},
emptyOutDir: false
Expand Down
17 changes: 10 additions & 7 deletions vite.config.build.taro.vue.disperse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import path from 'path';
const fs = require('fs-extra');
import config from './package.json';
import configPkg from './src/config.json';
import { terser } from 'rollup-plugin-terser';

const banner = `/*!
* ${config.name} v${config.version} ${new Date()}
Expand Down Expand Up @@ -62,12 +63,6 @@ declare module 'vue' {
],
build: {
minify: false,
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
},
lib: {
entry: '',
name: 'index',
Expand All @@ -84,7 +79,15 @@ declare module 'vue' {
'@/packages/locale': '../locale/lang'
},
dir: path.resolve(__dirname, './dist/packages/_es'),
entryFileNames: '[name].js'
entryFileNames: '[name].js',
plugins: [
terser({
compress: {
drop_console: true,
drop_debugger: true
}
})
]
}
},
emptyOutDir: false
Expand Down
17 changes: 10 additions & 7 deletions vite.config.build.taro.vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
import config from './package.json';
import { terser } from 'rollup-plugin-terser';

const banner = `/*!
* ${config.name} v${config.version} ${new Date()}
Expand Down Expand Up @@ -41,12 +42,6 @@ export default defineConfig({
],
build: {
minify: false,
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
},
rollupOptions: {
// 请确保外部化那些你的库中不需要的依赖
external: ['vue', 'vue-router', '@tarojs/taro'],
Expand All @@ -55,7 +50,15 @@ export default defineConfig({
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
globals: {
vue: 'Vue'
}
},
plugins: [
terser({
compress: {
drop_console: true,
drop_debugger: true
}
})
]
}
},
lib: {
Expand Down
18 changes: 10 additions & 8 deletions vite.config.build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import dts from 'vite-plugin-dts';
import vue from '@vitejs/plugin-vue';
import path from 'path';
import config from './package.json';

import { terser } from 'rollup-plugin-terser';
const banner = `/*!
* ${config.name} v${config.version} ${new Date()}
* (c) 2022 @jdf2e.
Expand Down Expand Up @@ -33,12 +33,6 @@ export default defineConfig({
plugins: [vue()],
build: {
minify: false,
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
},
rollupOptions: {
// 请确保外部化那些你的库中不需要的依赖
external: ['vue', 'vue-router'],
Expand All @@ -47,7 +41,15 @@ export default defineConfig({
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
globals: {
vue: 'Vue'
}
},
plugins: [
terser({
compress: {
drop_console: true,
drop_debugger: true
}
})
]
}
},
lib: {
Expand Down
11 changes: 10 additions & 1 deletion vite.config.jdt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import path from 'path';
import config from './package.json';
const hljs = require('highlight.js'); // https://highlightjs.org/
import { compressText } from './src/sites/doc/components/demo-block/basedUtil';
import { terser } from 'rollup-plugin-terser';
const resolve = path.resolve;
// https://vitejs.dev/config/
export default defineConfig({
Expand Down Expand Up @@ -100,7 +101,15 @@ export default defineConfig({
output: {
entryFileNames: `demo-${config.version}/[name].js`,
chunkFileNames: `demo-${config.version}/[name].js`,
assetFileNames: `demo-${config.version}/[name].[ext]`
assetFileNames: `demo-${config.version}/[name].[ext]`,
plugins: [
terser({
compress: {
drop_console: true,
drop_debugger: true
}
})
]
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import path from 'path';
import config from './package.json';
const hljs = require('highlight.js'); // https://highlightjs.org/
import { compressText } from './src/sites/doc/components/demo-block/basedUtil';
import { terser } from 'rollup-plugin-terser';
const resolve = path.resolve;
// https://vitejs.dev/config/
export default defineConfig({
Expand Down Expand Up @@ -100,7 +101,15 @@ export default defineConfig({
output: {
entryFileNames: `demo-${config.version}/[name].js`,
chunkFileNames: `demo-${config.version}/[name].js`,
assetFileNames: `demo-${config.version}/[name].[ext]`
assetFileNames: `demo-${config.version}/[name].[ext]`,
plugins: [
terser({
compress: {
drop_console: true,
drop_debugger: true
}
})
]
}
}
}
Expand Down

0 comments on commit c814f01

Please sign in to comment.