@@ -2,44 +2,48 @@ const path = require('path')
22const webpack = require ( 'webpack' )
33const CleanWebpackPlugin = require ( 'clean-webpack-plugin' )
44
5- var plugins = [
6- new CleanWebpackPlugin ( [ 'dist' ] ) ,
5+ let plugins = [
76 new webpack . DefinePlugin ( {
87 version : JSON . stringify ( require ( './package.json' ) . version ) ,
98 } )
109] ;
1110
12- module . exports = {
13- mode : 'none' ,
14- entry : path . resolve ( __dirname , 'src/index.js' ) ,
15- plugins : plugins ,
16- externals : {
17- clappr : 'Clappr'
18- } ,
19- module : {
20- rules : [
21- {
22- test : / \. j s $ / ,
23- loader : 'babel-loader'
24- } ,
25- {
26- test : / \. s v g / , loader : 'svg-inline-loader'
27- } ,
28- ] ,
29- } ,
30- resolve : {
31- extensions : [ '.js' ] ,
32- } ,
33- output : {
34- path : path . resolve ( __dirname , 'dist' ) ,
35- filename : 'clappr-pip.js' ,
36- library : 'ClapprPip' ,
37- libraryTarget : 'umd' ,
38- } ,
39- devServer : {
40- contentBase : 'public/' ,
41- host : '0.0.0.0' ,
42- disableHostCheck : true ,
43- inline : false
44- } ,
11+ module . exports = ( env , argv ) => {
12+ if ( argv . mode !== 'production' ) {
13+ plugins . push ( new CleanWebpackPlugin ( [ 'dist' ] ) ) ;
14+ }
15+ return {
16+ mode : argv . mode || 'none' ,
17+ entry : path . resolve ( __dirname , 'src/index.js' ) ,
18+ plugins : plugins ,
19+ externals : {
20+ clappr : 'Clappr'
21+ } ,
22+ module : {
23+ rules : [
24+ {
25+ test : / \. j s $ / ,
26+ loader : 'babel-loader'
27+ } ,
28+ {
29+ test : / \. s v g / , loader : 'svg-inline-loader'
30+ } ,
31+ ] ,
32+ } ,
33+ resolve : {
34+ extensions : [ '.js' ] ,
35+ } ,
36+ output : {
37+ path : path . resolve ( __dirname , 'dist' ) ,
38+ filename : 'clappr-pip.js' ,
39+ library : 'ClapprPip' ,
40+ libraryTarget : 'umd' ,
41+ } ,
42+ devServer : {
43+ contentBase : 'public/' ,
44+ host : '0.0.0.0' ,
45+ disableHostCheck : true ,
46+ inline : false
47+ } ,
48+ } ;
4549} ;
0 commit comments