UNPKG

897 BJavaScriptView Raw
1import resolve from 'rollup-plugin-node-resolve'
2import commonjs from 'rollup-plugin-commonjs'
3import json from 'rollup-plugin-json'
4import babel from 'rollup-plugin-babel'
5import babili from 'rollup-plugin-babili'
6import fs from 'fs-extra'
7
8// delete 'dist', so that copying the index.html works
9if (fs.existsSync('dist')) fs.emptyDirSync('dist')
10// create 'dist', should always fire
11if (!fs.existsSync('dist')) fs.mkdirSync('dist')
12// copy index.html to 'dist'
13fs.copySync('./site/index.html', './dist/index.html')
14
15let plugs = [
16 resolve({
17 main: true,
18 jsnext: true,
19 preferBuiltins: true
20 }),
21 commonjs(),
22 json(),
23 babel({
24 exclude: 'node_modules/**'
25 })
26]
27
28if (process.env.NODE_ENV === 'production') {
29 plugs.push(
30 babili({
31 comments: false
32 })
33 )
34}
35
36export default {
37 entry: './site/main.js',
38 dest: './dist/bundle.js',
39 format: 'es',
40 plugins: plugs
41}