1- import path from 'path' ;
2- import buble from 'rollup-plugin-buble' ;
3- import sizes from 'rollup-plugin-sizes' ;
4- import babel from 'rollup-plugin-babel' ;
5- import resolve from 'rollup-plugin-node-resolve' ;
1+ import { sizeSnapshot } from 'rollup-plugin-size-snapshot' ;
2+ import { terser } from 'rollup-plugin-terser' ;
3+ import babel from '@rollup/plugin-babel' ;
4+ import buble from '@rollup/plugin-buble' ;
65import builtins from 'rollup-plugin-node-builtins' ;
7- import vue from 'rollup-plugin-vue' ;
8- import commonjs from 'rollup-plugin-commonjs' ;
9- import replace from 'rollup-plugin-replace' ;
6+ import cleanup from 'rollup-plugin-cleanup' ;
7+ import commonjs from '@rollup/plugin-commonjs' ;
108import eslint from 'rollup-plugin-eslint' ;
11- import { terser } from 'rollup-plugin-terser' ;
9+ import path from 'path' ;
10+ import postcss from 'rollup-plugin-postcss' ;
11+ import replace from '@rollup/plugin-replace' ;
12+ import resolve from '@rollup/plugin-node-resolve' ;
13+ import visualizer from 'rollup-plugin-visualizer' ;
14+ import vue from 'rollup-plugin-vue' ;
1215
1316const RESOLVE_FIELDS = [ 'main' , 'browser' , 'jsnext' ] ;
1417
@@ -18,8 +21,30 @@ const {
1821 version,
1922} = require ( path . resolve ( process . cwd ( ) , 'package.json' ) ) ;
2023
24+ const banner =
25+ '/*!\n' +
26+ ` * Vue-datepicker v${ version } \n` +
27+ ` * (c) 2019-${ new Date ( ) . getFullYear ( ) } Mathieu Stanowski\n` +
28+ ' */' ;
29+
2130const plugins = [
31+ // -------------------------------------------
32+ // Lint files
33+ // -------------------------------------------
34+ eslint ( { exclude : [ '**/*.(scss|css)' ] } ) ,
35+ // -------------------------------------------
36+ // Allow node builtins
37+ // -------------------------------------------
2238 builtins ( ) ,
39+ // -------------------------------------------
40+ // 1. babel
41+ // 2. resolve => Locate modules for using third party modules in
42+ // 3. commonjs => used with resolve whioch allow to bundle your CommonJS dependencies in node_modules.
43+ // -------------------------------------------
44+ babel ( {
45+ exclude : 'node_modules/**' ,
46+ babelHelpers : 'runtime' ,
47+ } ) ,
2348 resolve ( { mainFields : RESOLVE_FIELDS } ) ,
2449 commonjs ( {
2550 include : 'node_modules/**' ,
@@ -33,20 +58,29 @@ const plugins = [
3358 ] ,
3459 } ,
3560 } ) ,
36- eslint ( ) ,
37- vue ( { template : { isProduction : true } } ) ,
38- babel ( {
39- exclude : 'node_modules/**' ,
40- runtimeHelpers : true ,
41- babelrc : false ,
61+ // -------------------------------------------
62+ // 1. postcss => Extract scss from imported scss files in js
63+ // 2. vue => Like vue-loader for webpack
64+ // 3. replace => Allows to set package.json version in bundle
65+ // -------------------------------------------
66+ postcss ( {
67+ use : [ 'sass' ] ,
68+ extract : 'vue-datepicker.min.css' ,
69+ minimize : true ,
4270 } ) ,
71+ vue ( { css : false , template : { isProduction : true } } ) ,
4372 replace ( {
4473 'process.env.NODE_ENV' : JSON . stringify ( 'production' ) ,
4574 VERSION : JSON . stringify ( version ) ,
4675 } ) ,
47- buble ( ) ,
48- sizes ( ) ,
49- terser ( ) ,
76+ // -------------------------------------------
77+ // Clean & Minify
78+ // -------------------------------------------
79+ cleanup ( ) ,
80+ sizeSnapshot ( ) ,
81+ buble ( ) , // convert ES2015+
82+ terser ( ) , // minifiy
83+ visualizer ( ) ,
5084] ;
5185
5286export default {
@@ -60,6 +94,7 @@ export default {
6094 'get-size' : 'getSize' ,
6195 'vue' : 'Vue' ,
6296 } ,
97+ banner,
6398 } ,
6499 plugins,
65100 watch : { include : 'src/**' } ,
0 commit comments