@@ -2,12 +2,15 @@ import path from 'path'
2
2
import Joi from 'joi'
3
3
import JadePlugin from './plugins/jade_plugin'
4
4
import CSSPlugin from './plugins/css_plugin'
5
+ import StaticPlugin from './plugins/static_plugin'
5
6
import micromatch from 'micromatch'
6
7
import union from 'lodash.union'
7
8
import _eval from 'require-from-string'
8
9
import { transformFileSync } from 'babel-core'
9
10
import postcssImport from 'postcss-import'
10
11
import BrowserSyncPlugin from 'browser-sync-webpack-plugin'
12
+ import binaryExtensions from 'binary-extensions'
13
+ import imageExtensions from 'image-extensions'
11
14
12
15
export default class Config {
13
16
constructor ( opts ) {
@@ -29,7 +32,8 @@ export default class Config {
29
32
matchers : Joi . object ( ) . default ( ) . keys ( {
30
33
jade : Joi . string ( ) . default ( '**/*.jade' ) ,
31
34
css : Joi . string ( ) . default ( '**/*.css' ) ,
32
- js : Joi . string ( ) . default ( '**/*.js' )
35
+ js : Joi . string ( ) . default ( '**/*.js' ) ,
36
+ static : Joi . string ( ) . default ( `**/*.{${ union ( binaryExtensions , imageExtensions ) . join ( ',' ) } }` )
33
37
} ) ,
34
38
postcss : Joi . object ( ) . default ( ) . keys ( {
35
39
plugins : Joi . array ( ) . default ( [ ] ) ,
@@ -130,10 +134,13 @@ export default class Config {
130
134
loaders : [
131
135
{ test : mmToRe ( opts . matchers . css ) , exclude : opts . ignore . map ( mmToRe ) , loader : `css!postcss?${ JSON . stringify ( opts . postcss . options ) } ` } ,
132
136
{ test : mmToRe ( opts . matchers . js ) , exclude : opts . ignore . map ( mmToRe ) , loader : 'babel' } ,
133
- { test : mmToRe ( opts . matchers . jade ) , exclude : opts . ignore . map ( mmToRe ) , loader : 'jade' , query : { pretty : true , locals : opts . locals } }
137
+ { test : mmToRe ( opts . matchers . jade ) , exclude : opts . ignore . map ( mmToRe ) , loader : 'jade' , query : { pretty : true , locals : opts . locals } } ,
138
+ { test : mmToRe ( opts . matchers . static ) , exclude : opts . ignore . map ( mmToRe ) , loader : 'file' , query : { dumpDirs : opts . dumpDirs } }
134
139
]
135
140
}
136
141
142
+ // console.log(mmToRe(opts.matchers.static))
143
+
137
144
this . postcss = function ( wp ) {
138
145
let res = [ postcssImport ( { addDependencyTo : wp } ) ]
139
146
res . push ( ...opts . postcss . plugins )
@@ -155,6 +162,10 @@ export default class Config {
155
162
ignore : opts . ignore ,
156
163
dumpDirs : opts . dumpDirs ,
157
164
cssTemplates : opts . cssTemplates
165
+ } ) , new StaticPlugin ( {
166
+ matcher : opts . matchers . static ,
167
+ ignore : opts . ignore ,
168
+ dumpDirs : opts . dumpDirs
158
169
} ) , new BrowserSyncPlugin ( opts . server )
159
170
]
160
171
0 commit comments