File tree 6 files changed +63
-1
lines changed
6 files changed +63
-1
lines changed Original file line number Diff line number Diff line change 19
19
"devDependencies" : {
20
20
"babel" : " ^5.8.20" ,
21
21
"babel-eslint" : " ^4.0.5" ,
22
+ "css-loader" : " ^0.21.0" ,
22
23
"css-modules-loader-core" : " ^1.0.0" ,
23
24
"eslint" : " ^1.0.0" ,
24
25
"eslint-config-airbnb" : " 0.0.7" ,
25
26
"eslint-config-airbnb-lite" : " ^1.0.3" ,
26
27
"eslint-watch" : " ^1.2.4" ,
28
+ "extract-text-webpack-plugin" : " ^0.8.2" ,
27
29
"in-publish" : " ^2.0.0" ,
28
30
"isparta" : " ^3.0.3" ,
29
31
"lodash" : " ^3.10.1" ,
30
32
"mocha" : " ^2.2.5" ,
31
33
"postcss" : " ^5.0.10" ,
34
+ "postcss-loader" : " ^0.7.0" ,
32
35
"postcss-modules-extract-imports" : " ^1.0.0" ,
33
36
"postcss-modules-local-by-default" : " ^1.0.0" ,
34
37
"postcss-modules-scope" : " ^1.0.0" ,
35
38
"postcss-modules-values" : " ^1.1.0" ,
36
- "precommit-hook" : " ^3.0.0"
39
+ "precommit-hook" : " ^3.0.0" ,
40
+ "style-loader" : " ^0.13.0" ,
41
+ "webpack" : " ^1.12.2"
37
42
},
38
43
"peerDependencies" : {
39
44
"postcss" : " ^5.x" ,
43
48
"postcss-modules-values" : " ^1.1.0"
44
49
},
45
50
"scripts" : {
51
+ "fixture" : " webpack" ,
46
52
"start" : " esw -w ." ,
47
53
"lint" : " eslint ." ,
48
54
"test" : " mocha --compilers js:babel/register" ,
Original file line number Diff line number Diff line change
1
+ result *
Original file line number Diff line number Diff line change
1
+ .local
2
+ {
3
+ color : white;
4
+ }
Original file line number Diff line number Diff line change
1
+ var css = require ( './source.css' ) ;
Original file line number Diff line number Diff line change
1
+ import { equal } from 'assert' ;
2
+ import { execSync } from 'child_process' ;
3
+ import { readFileSync } from 'fs' ;
4
+ import { resolve } from 'path' ;
5
+ import hook from '../src' ;
6
+
7
+ describe ( 'extractor' , ( ) => {
8
+ let selector ;
9
+
10
+ before ( ( ) => {
11
+ hook ( { generateScopedName : '[name]__[local]___[hash:base64:5]' } ) ;
12
+ execSync ( 'npm run fixture' , { cwd : process . cwd ( ) } ) ;
13
+ selector = readFileSync ( resolve ( 'test/cases/webpack/result.css' ) , 'utf8' )
14
+ . split ( '\n' ) . shift ( ) . replace ( / ^ \. / , '' ) ;
15
+ } ) ;
16
+
17
+ it ( 'should generate the same selectors as the webpack does' , ( ) => {
18
+ const tokens = require ( './cases/webpack/source.css' ) ;
19
+ equal ( selector , tokens . local ) ;
20
+ } ) ;
21
+ } ) ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ var ExtractTextPlugin = require ( 'extract-text-webpack-plugin' ) ;
4
+ var path = require ( 'path' ) ;
5
+
6
+ module . exports = {
7
+ entry : path . resolve ( 'test/cases/webpack/source.js' ) ,
8
+
9
+ output : {
10
+ filename : 'result.js' ,
11
+ path : path . resolve ( 'test/cases/webpack' )
12
+ } ,
13
+
14
+ module : {
15
+ loaders : [
16
+ {
17
+ test : / \. c s s $ / ,
18
+ loader : ExtractTextPlugin . extract ( 'style-loader' ,
19
+ 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader' )
20
+ }
21
+ ]
22
+ } ,
23
+
24
+ plugins : [
25
+ new ExtractTextPlugin ( 'result.css' , {
26
+ allChunks : true
27
+ } )
28
+ ]
29
+ } ;
You can’t perform that action at this time.
0 commit comments