-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
48 lines (42 loc) · 1.28 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
import globby from 'globby';
import babel from 'rollup-plugin-babel';
import html from 'rollup-plugin-html';
import del from 'rollup-plugin-delete';
import alias from '@rollup/plugin-alias';
import styles from 'rollup-plugin-styles';
import banner from 'rollup-plugin-banner';
import commonjs from 'rollup-plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import resolve from 'rollup-plugin-node-resolve';
// Clean dist folder on first run
del({ targets: 'dist/*' }).buildStart();
// Create a rollup config file for each entry JS file
const configFiles = globby.sync('./src/*.js').map(entryFile => {
const filenameNoExtension = (entryFile.match(/src\/(.*)\.js/) || [])[1];
return {
input: entryFile,
output: {
file: `./dist/${filenameNoExtension}.bundle.js`,
format: 'iife'
},
plugins: [
resolve(),
commonjs(),
terser(),
banner('jshint ignore: start'),
html({ include: '**/*.html' }),
styles({ mode: 'extract', onExtract: () => false }),
babel({
exclude: 'node_modules/**',
extensions: ['.js'],
presets: ['@babel/preset-env']
}),
alias({
entries: [
{ find: '@', replacement: `${__dirname}/src` }
]
})
]
};
});
export default configFiles;