File tree 2 files changed +37
-19
lines changed
2 files changed +37
-19
lines changed Original file line number Diff line number Diff line change 7
7
"commit-amend-build" : " scripts/commit-amend-build.sh" ,
8
8
"prebuild" : " rimraf dist/**" ,
9
9
"dev" : " cross-env NODE_ENV=development BABEL_ENV=rollup rollup -w -c -o dist/purify.js" ,
10
- "build" : " cross-env run-p build:umd build:umd:min build:es build:cjs" ,
11
- "build:umd" : " cross-env NODE_ENV=development BABEL_ENV=rollup rollup -c -f umd -o dist/purify.js" ,
12
- "build:umd:min" : " cross-env NODE_ENV=production BABEL_ENV=rollup rollup -c -f umd -o dist/purify.min.js" ,
13
- "build:es" : " cross-env NODE_ENV=development BABEL_ENV=rollup rollup -c -f es -o dist/purify.es.js" ,
14
- "build:cjs" : " cross-env NODE_ENV=development BABEL_ENV=rollup rollup -c -f cjs -o dist/purify.cjs.js" ,
10
+ "build" : " rollup -c" ,
15
11
"test:jsdom" : " cross-env NODE_ENV=test BABEL_ENV=rollup node test/jsdom-node-runner --dot" ,
16
12
"test:karma" : " cross-env NODE_ENV=test BABEL_ENV=rollup karma start test/karma.conf.js --log-level warn " ,
17
13
"test:ci" : " cross-env NODE_ENV=test BABEL_ENV=rollup npm run test:jsdom && npm run test:karma -- --log-level error --reporters dots --single-run --shouldTestOnBrowserStack=\" ${TEST_BROWSERSTACK}\" --shouldProbeOnly=\" ${TEST_PROBE_ONLY}\" " ,
20
16
"main" : " dist/purify.cjs.js" ,
21
17
"module" : " dist/purify.es.js" ,
22
18
"browser" : " dist/purify.js" ,
19
+ "production" : " dist/purify.min.js" ,
23
20
"files" : [
24
21
" dist"
25
22
],
Original file line number Diff line number Diff line change @@ -3,22 +3,47 @@ const babel = require('@rollup/plugin-babel').babel;
3
3
const nodeResolve = require ( '@rollup/plugin-node-resolve' ) . nodeResolve ;
4
4
const replace = require ( '@rollup/plugin-replace' ) ;
5
5
const { terser } = require ( 'rollup-plugin-terser' ) ;
6
+ const pkg = require ( './package.json' ) ;
6
7
7
8
const env = process . env . NODE_ENV ;
8
- const isProd = env === 'production' ;
9
9
const version = process . env . npm_package_version ;
10
- const license = fs . readFileSync ( './src/license_header' , 'utf8' ) . replace ( / V E R S I O N / ig, version ) ;
10
+ const license = fs
11
+ . readFileSync ( './src/license_header' , 'utf8' )
12
+ . replace ( / V E R S I O N / gi, version ) ;
13
+
14
+ const commonOutputConfig = {
15
+ name : 'DOMPurify' ,
16
+ sourcemap : true ,
17
+ banner : license ,
18
+ exports : 'default' ,
19
+ } ;
11
20
12
21
const config = {
13
22
input : 'src/purify.js' ,
14
23
external : [ ] ,
15
- output : {
16
- name : 'DOMPurify' ,
17
- globals : { } ,
18
- format : 'umd' ,
19
- sourcemap : true ,
20
- banner : license ,
21
- } ,
24
+ output : [
25
+ {
26
+ ...commonOutputConfig ,
27
+ file : pkg . browser ,
28
+ format : 'umd' ,
29
+ } ,
30
+ {
31
+ ...commonOutputConfig ,
32
+ file : pkg . production ,
33
+ format : 'umd' ,
34
+ plugins : [ terser ( ) ] ,
35
+ } ,
36
+ {
37
+ ...commonOutputConfig ,
38
+ file : pkg . module ,
39
+ format : 'es' ,
40
+ } ,
41
+ {
42
+ ...commonOutputConfig ,
43
+ file : pkg . main ,
44
+ format : 'cjs' ,
45
+ } ,
46
+ ] ,
22
47
plugins : [
23
48
babel ( {
24
49
// It is recommended to configure this option explicitly (even if with its default value) so an informed decision is taken on how those babel helpers are inserted into the code.
@@ -32,13 +57,9 @@ const config = {
32
57
values : {
33
58
'process.env.NODE_ENV' : JSON . stringify ( env ) ,
34
59
VERSION : `'${ version } '` ,
35
- }
60
+ } ,
36
61
} ) ,
37
62
] ,
38
63
} ;
39
64
40
- if ( isProd ) {
41
- config . plugins . push ( terser ( ) ) ;
42
- }
43
-
44
65
module . exports = config ;
You can’t perform that action at this time.
0 commit comments