Skip to content

Commit 9129041

Browse files
committed
Split rollup config for development/production
1 parent c60540e commit 9129041

File tree

3 files changed

+55
-12
lines changed

3 files changed

+55
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
],
3636
"scripts": {
3737
"build": "rollup -c && typedoc src",
38-
"watch": "rollup -c -w"
38+
"watch": "rollup -c -w --config rollup.dev.config.js"
3939
},
4040
"engines": {
4141
"node": ">=8.14.0"

rollup.config.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ import builtins from "rollup-plugin-node-builtins";
44
import typescript from "rollup-plugin-typescript2";
55
import { terser } from "rollup-plugin-terser";
66
import sourceMaps from "rollup-plugin-sourcemaps"
7-
import serve from "rollup-plugin-serve";
8-
import livereload from "rollup-plugin-livereload";
97

108
const name = "DAPjs";
119
const pkg = require('./package.json')
12-
const watch = process.env.ROLLUP_WATCH;
1310

1411
export default {
1512
input: "src/index.ts",
@@ -27,7 +24,7 @@ export default {
2724
}
2825
],
2926
plugins: [
30-
!watch && del({
27+
del({
3128
targets: [
3229
"dist/*",
3330
"types/*"
@@ -41,12 +38,6 @@ export default {
4138
useTsconfigDeclarationDir: true
4239
}),
4340
terser(),
44-
sourceMaps(),
45-
watch && serve({
46-
contentBase: ".",
47-
open: true,
48-
openPage: "/examples/daplink-flash/web.html",
49-
}),
50-
watch && livereload()
41+
sourceMaps()
5142
]
5243
};

rollup.dev.config.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import del from "rollup-plugin-delete";
2+
import tslint from "rollup-plugin-tslint";
3+
import builtins from "rollup-plugin-node-builtins";
4+
import typescript from "rollup-plugin-typescript2";
5+
import { terser } from "rollup-plugin-terser";
6+
import sourceMaps from "rollup-plugin-sourcemaps"
7+
import serve from "rollup-plugin-serve";
8+
import livereload from "rollup-plugin-livereload";
9+
10+
const name = "DAPjs";
11+
const pkg = require('./package.json')
12+
const watch = process.env.ROLLUP_WATCH;
13+
14+
export default {
15+
input: "src/index.ts",
16+
output: [
17+
{
18+
file: pkg.main,
19+
format: "umd",
20+
sourcemap: true,
21+
name
22+
},
23+
{
24+
file: pkg.module,
25+
format: "esm",
26+
sourcemap: true
27+
}
28+
],
29+
plugins: [
30+
!watch && del({
31+
targets: [
32+
"dist/*",
33+
"types/*"
34+
]
35+
}),
36+
tslint({
37+
throwOnError: true
38+
}),
39+
builtins(),
40+
typescript({
41+
useTsconfigDeclarationDir: true
42+
}),
43+
terser(),
44+
sourceMaps(),
45+
watch && serve({
46+
contentBase: ".",
47+
open: true,
48+
openPage: "/examples/daplink-flash/web.html",
49+
}),
50+
watch && livereload()
51+
]
52+
};

0 commit comments

Comments
 (0)