forked from wangeditor-team/wangEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprd.js
56 lines (51 loc) · 1.14 KB
/
prd.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* @description rollup prd config
* @author wangfupeng
*/
import babel from '@rollup/plugin-babel'
import postcss from 'rollup-plugin-postcss'
import autoprefixer from 'autoprefixer'
import cssnano from 'cssnano'
import { terser } from 'rollup-plugin-terser'
import cleanup from 'rollup-plugin-cleanup'
import genCommonConf from './common'
import { extensions } from './common'
/**
* 生成 prd config
* @param {string} format 'umd' 'esm'
*/
function genPrdConf(format) {
const { input, output = {}, plugins = [], external } = genCommonConf(format)
const finalPlugins = [
...plugins,
babel({
rootMode: 'upward',
babelHelpers: 'runtime',
exclude: 'node_modules/**',
include: 'src/**',
extensions,
}),
postcss({
plugins: [
autoprefixer(),
cssnano(), // 压缩 css
],
extract: 'css/style.css',
}),
cleanup({
comments: 'none',
extensions: ['.ts', '.tsx'],
}),
terser(), // 压缩 js
]
return {
input,
output: {
sourcemap: true,
...output,
},
external,
plugins: finalPlugins,
}
}
export default genPrdConf