-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
73 lines (73 loc) · 1.91 KB
/
rollup.config.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// import babel from "rollup-plugin-babel";
import resolve from "rollup-plugin-node-resolve";
import json from "rollup-plugin-json";
import commonjs from "rollup-plugin-commonjs";
import replace from "rollup-plugin-replace";//Global replacement
import uglify from "rollup-plugin-uglify";
import serve from "rollup-plugin-serve";
import livereload from "rollup-plugin-livereload";
import postcss from "rollup-plugin-postcss";
//post class
import simplevars from 'postcss-simple-vars';
import nested from 'postcss-nested';
import cssnext from 'postcss-cssnext';
import cssnano from 'cssnano';
//suport typescript
import typescriptPlugin from 'rollup-plugin-typescript';
import typescript from 'typescript';
export default {
input:"src/index.tsx",
output:{
file:"./dist/index.min.js",
format:"cjs"
},
plugins: [
postcss({
extensions:[".css","./scss"],
plugins:[
simplevars(),
nested(),
cssnext({ warnForDuplicates: false, }),
cssnano()
]
}),
resolve({
customResolveOptions: {
moduleDirectory: 'node_modules' // copywith the external
}
}),
commonjs(),
// babel({
// exclude: 'node_modules/**'
// }),
typescriptPlugin({
exclude: 'node_modules/**',
//import the vision of the lateset typescript
typescript,
importHelpers:true
}),
replace({
ENV:JSON.stringify(process.env.NODE_ENV||"development")//Global replace the ENV
}),
// production uglify
(process.env.NODE_ENV==="production"&&uglify({
compress:{
screw_ie8:true,
warning:false
},output: {
comments: false
},
sourceMap: false,
})),
serve({
open:true,//open the browser
contentBase:"./",
historyApiFallback:true,
host:"localhost",
port:8080
}),
livereload()
],
soucemap:process.env.NODE_ENV==="development"?true:false,
treeshake: true
}