1+ import minifyLit from '@mraerino/rollup-plugin-minifyliterals' ;
12import historyApi from 'connect-history-api-fallback' ;
23import * as fs from 'fs' ;
4+ import babel from 'rollup-plugin-babel' ;
35import minify from 'rollup-plugin-babel-minify' ;
6+ import browsersync from 'rollup-plugin-browsersync' ;
47import cjs from 'rollup-plugin-commonjs' ;
58import copy from 'rollup-plugin-copy' ;
69import nodeBuiltins from 'rollup-plugin-node-builtins' ;
710import nodeGlobals from 'rollup-plugin-node-globals' ;
811import nodeResolve from 'rollup-plugin-node-resolve' ;
9- import typescript from 'rollup-plugin-typescript2' ;
10- import minifyLit from '@mraerino/rollup-plugin-minifyliterals' ;
11- import browsersync from 'rollup-plugin-browsersync' ;
1212import replace from 'rollup-plugin-replace' ;
13+ import typescript from 'rollup-plugin-typescript2' ;
14+ import { uglify } from 'rollup-plugin-uglify' ;
1315import path from 'path' ;
1416
1517const distTarget = './build' ;
@@ -24,7 +26,7 @@ if (!fs.existsSync('build')) {
2426 fs . mkdirSync ( 'build' ) ;
2527}
2628
27- const plugins = [
29+ const basePlugins = [
2830 replace ( {
2931 'process.env.NODE_ENV' : JSON . stringify ( process . env . NODE_ENV || 'development' )
3032 } ) ,
@@ -58,45 +60,52 @@ const plugins = [
5860 typescript ( ) ,
5961 cjs ( ) ,
6062 nodeGlobals ( ) , // WARNING: Never move above CommonJS plugin!
61- isProduction ? minifyLit ( {
63+ isProduction && minifyLit ( {
6264 include : [ 'src/entry.ts' , 'src/{components,views}/**' , 'node_modules/@polymer/{paper,iron}-*/**' ] ,
6365 includeExtension : [ '.ts' , '.js' ] ,
6466 literals : false ,
6567 htmlminifier : {
6668 minifyCSS : true , // causes some kind of trouble currently
6769 collapseWhitespace : true
6870 }
69- } ) : null ,
70- isProduction ? minify ( { comments : false } ) : null ,
71- ! ! process . env . ROLLUP_WATCH ? browsersync ( {
72- port : process . env . PORT || 3000 ,
73- server : {
74- baseDir : dist ( ) ,
75- middleware : [ historyApi ( ) ]
76- } ,
77- open : false ,
78- ui : false
79- } ) : null ,
80- ] . filter ( plugin => plugin !== null ) ;
71+ } ) ,
72+ ] ;
8173
8274const baseOptions = {
8375 input : [ src ( 'index.ts' ) , src ( 'views/view-party.ts' ) , src ( 'views/view-tv.ts' ) ] ,
8476 experimentalDynamicImport : true ,
8577 experimentalCodeSplitting : true ,
86- plugins,
8778 onwarn : err => console . error ( err . toString ( ) ) ,
8879 watch : { include : 'src/**/*' } ,
8980} ;
9081
9182export default [ {
9283 ...baseOptions ,
84+ plugins : [
85+ ...basePlugins ,
86+ // isProduction && minify({ comments: false }),
87+ ! ! process . env . ROLLUP_WATCH && browsersync ( {
88+ port : process . env . PORT || 3000 ,
89+ server : {
90+ baseDir : dist ( ) ,
91+ middleware : [ historyApi ( ) ]
92+ } ,
93+ open : false ,
94+ ui : false
95+ } ) ,
96+ ] . filter ( plugin => plugin ) ,
9397 output : {
9498 dir : dist ( 'module' ) ,
9599 format : 'es' ,
96100 sourcemap : true ,
97101 } ,
98102} , {
99103 ...baseOptions ,
104+ plugins : [
105+ ...basePlugins ,
106+ babel ( ) ,
107+ isProduction && uglify ( ) ,
108+ ] . filter ( plugin => plugin ) ,
100109 output : {
101110 dir : dist ( 'nomodule' ) ,
102111 format : 'system' ,
0 commit comments