1
- require ( 'es6-promise' ) . polyfill ( ) ; // fixes https://github.com/webpack/css-loader/issues/145
2
-
3
- var webpack = require ( ' webpack' ) ;
4
- var ExtractTextPlugin = require ( ' extract-text-webpack-plugin' ) ;
1
+ "use strict" ;
2
+ const path = require ( "path" ) ;
3
+ const webpack = require ( " webpack" ) ;
4
+ const ExtractTextPlugin = require ( " extract-text-webpack-plugin" ) ;
5
5
var Clean = require ( 'clean-webpack-plugin' ) ;
6
6
7
- var siteConfig = {
7
+ const cssLoaders = [
8
+ {
9
+ loader : "css-loader" ,
10
+ options : {
11
+ modules : true ,
12
+ minimize : true
13
+ }
14
+ } ,
15
+ {
16
+ loader : "sass-loader"
17
+ }
18
+ ]
19
+ module . exports = {
20
+ context : __dirname + "/source" ,
8
21
entry : {
9
- site : [
10
- './source/ stylesheets/site.css .scss' ,
11
- './source/ javascripts/site.js'
22
+ site : [
23
+ './stylesheets/site.scss' ,
24
+ './javascripts/site.js'
12
25
] ,
13
26
} ,
14
-
15
- resolve : {
16
- root : __dirname + '/source/javascripts' ,
17
- } ,
18
-
19
- output : {
20
- path : __dirname + '/.tmp/dist' ,
21
- filename : 'javascripts/[name].bundle.js' ,
22
- } ,
23
-
24
27
module : {
25
- loaders : [
26
- // Load JS
27
- {
28
- test : / s o u r c e \/ j a v a s c r i p t s \/ .* \. j s $ / ,
29
- exclude : / n o d e _ m o d u l e s | \. t m p | v e n d o r / ,
30
- loader : 'babel-loader' ,
31
- query : {
32
- presets : [ 'es2015' , 'stage-0' ]
33
- } ,
34
- } ,
35
- // Load SCSS
28
+ rules : [
36
29
{
37
- test : / \. s c s s $ / ,
38
- loader : ExtractTextPlugin . extract (
39
- "style" ,
40
- "css!sass?sourceMap"
41
- )
30
+ test : / \. j s $ / ,
31
+ exclude : / ( n o d e _ m o d u l e s ) / ,
32
+ loader : "babel-loader" ,
42
33
} ,
43
-
44
- // Embed small pngs as data uri
45
- // url-loader falls back to file-loader when image is too big
46
34
{
47
- test : / \. ( j p e ? g | p n g | g i f | s v g ) $ / i,
48
- loader : "url-loader?limit=100000&name=../images/[name].[ext]"
35
+ test : / \. ( s a s s | s c s s ) $ / ,
36
+ use : ExtractTextPlugin . extract ( {
37
+ fallback : "style-loader" ,
38
+ use : "css-loader"
39
+ } )
49
40
} ,
50
- ] ,
51
- } ,
52
-
53
- sassLoader : {
54
- includePaths : [ require ( 'bourbon' ) . includePaths ]
41
+ ] , //end rules
55
42
} ,
56
-
57
- node : {
58
- console : true
43
+ output : {
44
+ path : __dirname + "/build/" ,
45
+ filename : "[name].bundle.js" ,
59
46
} ,
60
47
61
48
plugins : [
62
- new Clean ( [ '.tmp' ] ) ,
63
- new ExtractTextPlugin ( "stylesheets/site.bundle.css" ) ,
64
- new webpack . optimize . CommonsChunkPlugin ( "site" , "javascripts/site.bundle.js" ) ,
49
+ new Clean ( [ '.build' ] ) ,
50
+ new webpack . LoaderOptionsPlugin ( {
51
+ minimize : true ,
52
+ debug : false
53
+ } ) ,
54
+ new ExtractTextPlugin ( {
55
+ filename : ( getPath ) => {
56
+ return getPath ( "[name].bundle.css" ) . replace ( "css/js" , "css" ) ;
57
+ } ,
58
+ disable : false ,
59
+ allChunks : true ,
60
+ } ) ,
65
61
] ,
66
62
} ;
67
-
68
- module . exports = siteConfig ;
0 commit comments