File tree Expand file tree Collapse file tree 6 files changed +63
-1
lines changed Expand file tree Collapse file tree 6 files changed +63
-1
lines changed Original file line number Diff line number Diff line change 1919 "devDependencies" : {
2020 "babel" : " ^5.8.20" ,
2121 "babel-eslint" : " ^4.0.5" ,
22+ "css-loader" : " ^0.21.0" ,
2223 "css-modules-loader-core" : " ^1.0.0" ,
2324 "eslint" : " ^1.0.0" ,
2425 "eslint-config-airbnb" : " 0.0.7" ,
2526 "eslint-config-airbnb-lite" : " ^1.0.3" ,
2627 "eslint-watch" : " ^1.2.4" ,
28+ "extract-text-webpack-plugin" : " ^0.8.2" ,
2729 "in-publish" : " ^2.0.0" ,
2830 "isparta" : " ^3.0.3" ,
2931 "lodash" : " ^3.10.1" ,
3032 "mocha" : " ^2.2.5" ,
3133 "postcss" : " ^5.0.10" ,
34+ "postcss-loader" : " ^0.7.0" ,
3235 "postcss-modules-extract-imports" : " ^1.0.0" ,
3336 "postcss-modules-local-by-default" : " ^1.0.0" ,
3437 "postcss-modules-scope" : " ^1.0.0" ,
3538 "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"
3742 },
3843 "peerDependencies" : {
3944 "postcss" : " ^5.x" ,
4348 "postcss-modules-values" : " ^1.1.0"
4449 },
4550 "scripts" : {
51+ "fixture" : " webpack" ,
4652 "start" : " esw -w ." ,
4753 "lint" : " eslint ." ,
4854 "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