1
- var path = require ( 'path' ) ;
2
- var webpack = require ( 'webpack' ) ;
3
- var BundleTracker = require ( 'webpack-bundle-tracker' ) ;
1
+ /* global __dirname, module, require */
2
+ const path = require ( 'path' ) ;
3
+ const webpack = require ( 'webpack' ) ;
4
+ const BundleTracker = require ( 'webpack-bundle-tracker' ) ;
4
5
5
6
module . exports = {
6
- //the base directory (absolute path) for resolving the entry option
7
7
context : __dirname ,
8
- //the entry point we created earlier. Note that './' means
9
- //your current directory. You don't have to specify the extension now,
10
- //because you will specify extensions later in the `resolve` section
11
8
entry : [ 'babel-polyfill' , './assets/js/index' ] ,
12
9
13
10
output : {
14
- //where you want your compiled bundle to be stored
15
11
path : path . resolve ( './assets/bundles/' ) ,
16
- //naming convention webpack should use for your files
17
- filename : '[name]-[hash].js'
12
+ filename : '[name]-[hash].js' ,
18
13
} ,
19
14
20
15
plugins : [
21
- //tells webpack where to store data about your bundles.
16
+ // Store data about bundles in './webpack-stats.json' .
22
17
new BundleTracker ( { filename : './webpack-stats.json' } ) ,
23
- //makes jQuery available in every module
18
+ // Make jQuery available in every module.
24
19
new webpack . ProvidePlugin ( {
25
20
$ : 'jquery' ,
26
21
jQuery : 'jquery' ,
27
- 'window.jQuery' : 'jquery'
28
- } )
22
+ 'window.jQuery' : 'jquery' ,
23
+ } ) ,
29
24
] ,
30
25
31
26
module : {
32
- loaders : [
33
- //a regexp that tells webpack use the following loaders on all
34
- //.js and .jsx files
35
- { test : / \. j s x ? $ / ,
36
- //we definitely don't want babel to transpile all the files in
37
- //node_modules. That would take a long time.
27
+ rules : [
28
+ {
29
+ test : / \. j s x ? $ / ,
38
30
exclude : / n o d e _ m o d u l e s / ,
39
- // use the babel loader
40
- loader : 'babel-loader' ,
41
- query : {
42
- //specify that we will be dealing with React code
43
- presets : [ 'react' , 'env' ]
44
- }
45
- }
46
- ]
31
+ use : {
32
+ loader : 'babel-loader' ,
33
+ options : {
34
+ presets : [ 'react' , 'env' ] ,
35
+ } ,
36
+ } ,
37
+ } ,
38
+ ] ,
47
39
} ,
48
40
49
41
resolve : {
50
- //tells webpack where to look for modules
51
42
modules : [ 'node_modules' ] ,
52
- //extensions that should be used to resolve modules
53
- extensions : [ '.js' , '.jsx' ]
54
- }
55
- }
43
+ extensions : [ '.js' , '.jsx' ] ,
44
+ } ,
45
+ } ;
0 commit comments