-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
79 lines (74 loc) · 2.05 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
import path from 'path';
import copy from 'rollup-plugin-copy';
import postcss from 'rollup-plugin-postcss';
import autoprefixer from 'autoprefixer';
import cssnano from 'cssnano';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser';
import serve from 'rollup-plugin-serve';
import livereload from 'rollup-plugin-livereload';
const production = process.env.NODE_ENV === 'production';
const development = process.env.NODE_ENV === 'development';
const extensions = ['.ts', '.tsx'];
export default {
input: 'src/index.ts',
plugins: [
copy({
targets: [
{ src: 'src/*.html', dest: 'dist' },
{ src: 'src/assets', dest: 'dist' }
]
}),
postcss({
plugins: [
autoprefixer,
cssnano({
preset: ['default', { discardComments: { removeAll: true } }]
})
],
extract: 'css/bundle.min.css',
sourceMap: production ? false : 'inline'
}),
resolve({ extensions }),
commonjs(),
babel({
extensions,
babelHelpers: 'bundled',
include: ['src/**/*'],
exclude: ['node_modules/**', 'dist']
}),
production && terser(),
development &&
serve({
open: true,
contentBase: 'dist',
historyApiFallback: true,
host: 'localhost',
port: 3000,
onListening: function (server) {
const address = server.address();
const host = address.address === '::' ? 'localhost' : address.address;
const protocol = this.https ? 'https' : 'http';
console.log(
'\n',
`Server listening at ${protocol}://${host}:${address.port}/`,
'\n'
);
}
}),
development &&
livereload({
watch: [path.resolve(__dirname, 'src')],
exts: ['html', 'ts', 'scss'],
verbose: false
})
],
output: {
dir: 'dist',
format: 'iife',
name: 'bundle',
entryFileNames: 'js/main.min.js'
}
};