11const path = require ( 'path' ) ;
22const webpack = require ( 'webpack' ) ;
33const escapeRegExp = require ( 'lodash/escapeRegExp' ) ;
4+ const startsWith = require ( 'lodash/startsWith' ) ;
5+ const map = require ( 'lodash/map' ) ;
6+ const includes = require ( 'lodash/includes' ) ;
47
58function matchModule ( modulePath ) {
6- return new RegExp ( `\\/node_modules\\/${ escapeRegExp ( modulePath ) } ` ) ;
9+ const modulePattern = new RegExp (
10+ `\\/node_modules\\/${ escapeRegExp ( modulePath ) } `
11+ ) ;
12+ const moduleDependencyPattern = new RegExp (
13+ `\\/node_modules\\/${ escapeRegExp ( modulePath ) } \\/node_modules`
14+ ) ;
15+
16+ return ( filePath ) =>
17+ modulePattern . test ( filePath ) && ! moduleDependencyPattern . test ( filePath ) ;
18+ }
19+
20+ function directoryContentsExcept ( directory , exceptions ) {
21+ const fullExceptions = map (
22+ exceptions ,
23+ ( exception ) => path . resolve ( directory , exception )
24+ ) ;
25+
26+ return ( filePath ) =>
27+ startsWith ( filePath , path . resolve ( directory ) ) &&
28+ ! includes ( fullExceptions , filePath ) ;
729}
830
931module . exports = {
@@ -22,36 +44,34 @@ module.exports = {
2244 path . resolve ( __dirname , 'src' ) ,
2345 path . resolve ( __dirname , 'spec' ) ,
2446 ] ,
25- loaders : [ 'babel-loader' , 'transform/cacheable?brfs-babel' ] ,
47+ loaders : [ 'babel-loader' , 'transform-loader /cacheable?brfs-babel' ] ,
2648 } ,
2749 {
2850 test : / \. j s $ / ,
2951 include : [
3052 path . resolve ( __dirname , 'node_modules/htmllint' ) ,
3153 ] ,
32- loader : 'transform/cacheable?bulkify' ,
54+ loader : 'transform-loader /cacheable?bulkify' ,
3355 } ,
3456 {
3557 test : / \. j s $ / ,
3658 include : [
3759 path . resolve ( __dirname , 'node_modules/PrettyCSS' ) ,
3860 path . resolve ( __dirname , 'node_modules/css' ) ,
3961 ] ,
40- loader : 'transform/cacheable?brfs' ,
62+ loader : 'transform-loader /cacheable?brfs' ,
4163 } ,
4264 {
4365 test : / \. j s $ / ,
4466 include : [
4567 path . resolve ( __dirname , 'node_modules/postcss/lib/previous-map' ) ,
46- path . resolve ( __dirname , 'node_modules/stylelint/dist/getPostcssResult' ) ,
47- path . resolve ( __dirname ,
48- 'node_modules/stylelint/node_modules/sugarss/node_modules/postcss/lib/previous-map'
49- ) ,
50- path . resolve ( __dirname ,
51- 'node_modules/stylelint/node_modules/postcss-scss/node_modules/postcss/lib/previous-map'
68+ path . resolve (
69+ __dirname ,
70+ 'node_modules/stylelint/dist/getPostcssResult'
5271 ) ,
72+ matchModule ( 'postcss/lib/previous-map' ) ,
5373 ] ,
54- loader : 'string-replace' ,
74+ loader : 'string-replace-loader ' ,
5575 query : {
5676 search : / r e q u i r e \( [ ' " ] f s [ ' " ] \) / ,
5777 replace : '{}' ,
@@ -65,15 +85,15 @@ module.exports = {
6585 'node_modules/stylelint/dist/utils/isAutoprefixable'
6686 ) ,
6787 ] ,
68- loader : 'substitute' ,
88+ loader : 'substitute-loader ' ,
6989 query : { content : '() => false' } ,
7090 } ,
7191 {
7292 test : / \. j s $ / ,
7393 include : [
74- path . resolve ( __dirname , 'node_modules/ redux') ,
75- path . resolve ( __dirname , 'node_modules/ lodash-es') ,
76- path . resolve ( __dirname , 'node_modules/ github-api') ,
94+ matchModule ( ' redux') ,
95+ matchModule ( ' lodash-es') ,
96+ matchModule ( ' github-api') ,
7797 ] ,
7898 loader : 'babel-loader' ,
7999 } ,
@@ -82,7 +102,7 @@ module.exports = {
82102 include : [
83103 path . resolve ( __dirname , 'node_modules/loop-protect' ) ,
84104 ] ,
85- loader : 'imports?define=>false' ,
105+ loader : 'imports-loader ?define=>false' ,
86106 } ,
87107 {
88108 include : [
@@ -91,26 +111,30 @@ module.exports = {
91111 'node_modules/html-inspector/html-inspector.js'
92112 ) ,
93113 ] ,
94- loader : 'imports?window=>{}!exports?window.HTMLInspector' ,
114+ loader :
115+ 'imports-loader?window=>{}!exports-loader?window.HTMLInspector' ,
95116 } ,
96117 {
97118 test : / \. j s $ / ,
98119 include : [
99120 path . resolve ( __dirname , 'node_modules/brace/worker' ) ,
100- path . resolve (
101- __dirname ,
102- 'node_modules/stylelint/dist/rules/no-unsupported-browser-features'
103- ) ,
104- path . resolve (
105- __dirname ,
106- 'node_modules/stylelint/dist/rules/no-browser-hacks'
107- ) ,
108121 matchModule ( 'autoprefixer' ) ,
109122 matchModule ( 'postcss-scss' ) ,
110123 matchModule ( 'postcss-less' ) ,
111124 matchModule ( 'sugarss' ) ,
112125 ] ,
113- loader : 'null' ,
126+ loader : 'null-loader' ,
127+ } ,
128+ {
129+ test : / \. j s $ / ,
130+ include : directoryContentsExcept (
131+ 'node_modules/stylelint/dist/rules' ,
132+ [
133+ 'index.js' ,
134+ 'declaration-block-trailing-semicolon/index.js' ,
135+ ]
136+ ) ,
137+ loader : 'null-loader' ,
114138 } ,
115139 {
116140 test : / \. j s o n $ / ,
0 commit comments