11const path = require ( 'path' ) ;
22const webpack = require ( 'webpack' ) ;
33const MomentLocalesPlugin = require ( 'moment-locales-webpack-plugin' ) ;
4+ const pluginArray = [ ] ;
5+ const sourceMapType = 'source-map' ;
46
7+ /*if (process.env.NODE_ENV !== 'development') {
8+ console.log('Development environment detected, enabling Bundle Analyzer');
9+ const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
510
6- var pluginArray = [ ] ;
11+ pluginArray.push(new BundleAnalyzerPlugin({
12+ // Can be `server`, `static` or `disabled`.
13+ // In `server` mode analyzer will start HTTP server to show bundle report.
14+ // In `static` mode single HTML file with bundle report will be generated.
15+ // In `disabled` mode you can use this plugin to just generate Webpack Stats JSON file by setting
16+ // `generateStatsFile` to `true`.
17+ analyzerMode: 'static',
18+ // Host that will be used in `server` mode to start HTTP server.
19+ analyzerHost: '127.0.0.1',
20+ // Port that will be used in `server` mode to start HTTP server.
21+ analyzerPort: 8888,
22+ // Path to bundle report file that will be generated in `static` mode.
23+ // Relative to bundles output directory.
24+ reportFilename: 'bundle_report.html',
25+ // Module sizes to show in report by default.
26+ // Should be one of `stat`, `parsed` or `gzip`.
27+ // See "Definitions" section for more information.
28+ defaultSizes: 'parsed',
29+ // Automatically open report in default browser
30+ openAnalyzer: true,
31+ // If `true`, Webpack Stats JSON file will be generated in bundles output directory
32+ generateStatsFile: false,
33+ // Name of Webpack Stats JSON file that will be generated if `generateStatsFile` is `true`.
34+ // Relative to bundles output directory.
35+ statsFilename: 'stats.json',
36+ // Options for `stats.toJson()` method.
37+ // For example you can exclude sources of your modules from stats file with `source: false` option.
38+ // See more options here: https://github.com/webpack/webpack/blob/webpack-1/lib/Stats.js#L21
39+ statsOptions: null,
40+ // Log level. Can be 'info', 'warn', 'error' or 'silent'.
41+ logLevel: 'info'
42+ }));
43+ }*/
744
8- var sourceMapType = 'source-map' ;
9-
10- if ( process . env . NODE_ENV !== 'development' ) {
11-
12- /*
13- console.log('Development environment detected, enabling Bundle Analyzer');
14-
15- var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
16-
17- pluginArray.push(new BundleAnalyzerPlugin({
18- // Can be `server`, `static` or `disabled`.
19- // In `server` mode analyzer will start HTTP server to show bundle report.
20- // In `static` mode single HTML file with bundle report will be generated.
21- // In `disabled` mode you can use this plugin to just generate Webpack Stats JSON file by setting `generateStatsFile` to `true`.
22- analyzerMode: 'static',
23- // Host that will be used in `server` mode to start HTTP server.
24- analyzerHost: '127.0.0.1',
25- // Port that will be used in `server` mode to start HTTP server.
26- analyzerPort: 8888,
27- // Path to bundle report file that will be generated in `static` mode.
28- // Relative to bundles output directory.
29- reportFilename: 'bundle_report.html',
30- // Module sizes to show in report by default.
31- // Should be one of `stat`, `parsed` or `gzip`.
32- // See "Definitions" section for more information.
33- defaultSizes: 'parsed',
34- // Automatically open report in default browser
35- openAnalyzer: true,
36- // If `true`, Webpack Stats JSON file will be generated in bundles output directory
37- generateStatsFile: false,
38- // Name of Webpack Stats JSON file that will be generated if `generateStatsFile` is `true`.
39- // Relative to bundles output directory.
40- statsFilename: 'stats.json',
41- // Options for `stats.toJson()` method.
42- // For example you can exclude sources of your modules from stats file with `source: false` option.
43- // See more options here: https://github.com/webpack/webpack/blob/webpack-1/lib/Stats.js#L21
44- statsOptions: null,
45- // Log level. Can be 'info', 'warn', 'error' or 'silent'.
46- logLevel: 'info'
47- }));
48- */
49-
50- }
51-
52- var jq = new webpack . ProvidePlugin ( {
53- $ : "jquery" ,
54- jQuery : "jquery" ,
55- "window.jQuery" : "jquery'" ,
56- "window.$" : "jquery"
57- } ) ;
58-
59- pluginArray . push ( jq ) ;
45+ pluginArray . push ( new webpack . ProvidePlugin ( {
46+ $ : 'jquery' ,
47+ jQuery : 'jquery' ,
48+ 'window.jQuery' : 'jquery' ,
49+ 'window.$' : 'jquery'
50+ } ) ) ;
6051
6152// Strip all locales except the ones defined in lib/language.js
6253// (“en” is built into Moment and can’t be removed, 'dk' is not defined in moment)
63- var momentLocales = new MomentLocalesPlugin ( {
64- localesToKeep : [ 'bg' , 'cs' , 'de' , 'el' , 'es' , 'fi' , 'fr' , 'he' , 'hr' , 'it' , 'ko' , 'nb' , 'nl' , 'pl' , 'pt' , 'ro' , 'ru' , 'sk' , 'sv' , 'zh_cn' , 'zh_tw' ] ,
65- } ) ;
66- pluginArray . push ( momentLocales ) ;
67-
54+ pluginArray . push ( new MomentLocalesPlugin ( {
55+ localesToKeep : [ 'bg' , 'cs' , 'de' , 'el' , 'es' , 'fi' , 'fr' , 'he' , 'hr' , 'it' , 'ko' , 'nb' , 'nl' , 'pl' , 'pt' , 'ro' , 'ru' ,
56+ 'sk' , 'sv' , 'zh_cn' , 'zh_tw' ] ,
57+ } ) ) ;
6858
6959module . exports = {
70- context : path . resolve ( __dirname , '.' ) ,
71- entry : {
72- app : './bundle/bundle.source.js'
73- } ,
74- output : {
75- path : path . resolve ( __dirname , './tmp' ) ,
76- publicPath : '/' ,
77- filename : 'js/bundle.js' ,
78- sourceMapFilename : "js/bundle.js.map" ,
60+ context : path . resolve ( __dirname , '.' ) ,
61+ entry : {
62+ app : './bundle/bundle.source.js'
63+ } ,
64+ output : {
65+ path : path . resolve ( __dirname , './tmp' ) ,
66+ publicPath : '/' ,
67+ filename : 'js/bundle.js' ,
68+ sourceMapFilename : 'js/bundle.js.map' ,
69+ } ,
70+ devtool : sourceMapType ,
71+ plugins : pluginArray ,
72+ module : {
73+ rules : [ {
74+ test : / \. ( j p e ? g | p n g | g i f ) $ / i,
75+ loader : 'file-loader' ,
76+ query : {
77+ name : '[name].[ext]' ,
78+ outputPath : 'images/'
79+ //the images will be emmited to public/assets/images/ folder
80+ //the images will be put in the DOM <style> tag as eg. background: url(assets/images/image.png);
81+ } ,
82+ exclude : / n o d e _ m o d u l e s /
7983 } ,
80- devtool : sourceMapType ,
81- plugins : pluginArray ,
82- module : {
83- rules : [ {
84- test : / \. ( j p e ? g | p n g | g i f ) $ / i,
85- loader : "file-loader" ,
86- query : {
87- name : '[name].[ext]' ,
88- outputPath : 'images/'
89- //the images will be emmited to public/assets/images/ folder
90- //the images will be put in the DOM <style> tag as eg. background: url(assets/images/image.png);
91- }
92- } ,
93- {
94- test : / \. c s s $ / ,
95- loaders : [ "style-loader" , "css-loader" ]
96- } , {
97- test : require . resolve ( 'jquery' ) ,
98- use : [ {
99- loader : 'expose-loader' ,
100- options : '$'
101- } ]
102- }
103- ]
104- }
84+ {
85+ test : / \. c s s $ / ,
86+ loaders : [ 'style-loader' , 'css-loader' ] ,
87+ exclude : / n o d e _ m o d u l e s /
88+ } ,
89+ {
90+ test : require . resolve ( 'jquery' ) ,
91+ use : [ {
92+ loader : 'expose-loader' ,
93+ options : '$'
94+ } ]
95+ }
96+ ]
97+ }
10598} ;
0 commit comments