-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
101 lines (87 loc) · 2.39 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import commonjs from '@rollup/plugin-commonjs';
import autoprefixer from 'autoprefixer';
import path from 'path';
// import postcssCssnext from 'postcss-cssnext'; // For IE 11
import postcssImport from 'postcss-import';
import postcssMixins from 'postcss-mixins';
import postcssNested from 'postcss-nested';
import postcssPresetEnv from 'postcss-preset-env';
import babel from 'rollup-plugin-babel';
import livereload from 'rollup-plugin-livereload';
import resolve from 'rollup-plugin-node-resolve';
import postcss from 'rollup-plugin-postcss';
import serve from 'rollup-plugin-serve';
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';
const NAME = 'testUce'; // for umd
const { NODE_ENV = 'development' } = process.env;
const isProduction = NODE_ENV === 'production';
const INPUT_DIR = 'src';
const INPUT = `${INPUT_DIR}/index.ts`;
const OUTPUT_DIR = 'dist';
const BUNDLE_NAME = `${OUTPUT_DIR}/bundle.js`;
const DEV_PORT = 3000;
const FORMAT = 'umd';
const SOURCEMAP = isProduction ? false : 'inline';
export default {
input: INPUT,
output: {
sourcemap: SOURCEMAP,
format: FORMAT,
name: NAME,
file: BUNDLE_NAME,
},
plugins: [
resolve(),
postcss({
extract: path.resolve('dist/app.css'),
modules: false,
plugins: [
postcssImport,
postcssNested,
postcssMixins,
postcssPresetEnv({
autoprefixer,
browsers: ['> 1%', 'last 2 versions', 'IE 11'],
}),
//
// Or preprocess all css variables to CSS values for use in IE 11 using postcss-cssnext:
//
// postcssCssnext({
// browsers: ['> 1%', 'last 2 versions', 'IE 11'],
// }),
],
sourceMap: true,
}),
commonjs(),
typescript(),
babel({
presets: [
[
'@babel/preset-env',
{
modules: false,
targets: {
chrome: '58',
ie: '11',
},
},
],
],
}),
!isProduction &&
serve({
contentBase: [OUTPUT_DIR],
port: DEV_PORT,
}),
!isProduction &&
livereload({
watch: [INPUT_DIR, OUTPUT_DIR],
}),
isProduction && terser(),
isProduction && sizeSnapshot(),
].filter(Boolean),
context: 'null',
moduleContext: 'null',
};