File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed
Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ module.exports = function(content) {
1717 }
1818
1919 {
20- let classes = getClasses ( content ) ;
20+ const classes = getClasses ( content ) ;
2121
2222 if ( options . namedExport ) {
2323 for ( let c of classes ) {
@@ -49,11 +49,20 @@ function getClasses(content) {
4949 /** @type {string[] } */
5050 let classes = [ ] ;
5151
52- /** @type {RegExpExecArray } */
53- let match ;
54- while ( match = classesRegex . exec ( content ) ) {
55- if ( classes . indexOf ( match [ 1 ] ) === - 1 ) {
56- classes . push ( match [ 1 ] ) ;
52+ // when `exportOnlyLocals` is on
53+ let from = content . indexOf ( 'module.exports = {' ) ;
54+ // when `exportOnlyLocals` is off
55+ from = ~ from ? from : content . indexOf ( 'exports.locals = {' ) ;
56+
57+ if ( ~ from ) {
58+ content = content . substr ( from ) ;
59+
60+ /** @type {RegExpExecArray } */
61+ let match ;
62+ while ( match = classesRegex . exec ( content ) ) {
63+ if ( classes . indexOf ( match [ 1 ] ) === - 1 ) {
64+ classes . push ( match [ 1 ] ) ;
65+ }
5766 }
5867 }
5968
Original file line number Diff line number Diff line change 11{
22 "name" : " dts-css-modules-loader" ,
3- "version" : " 1.0.0 " ,
3+ "version" : " 1.0.1 " ,
44 "description" : " webpack loader to generate typings for css modules" ,
55 "dependencies" : {
66 "loader-utils" : " ^1.2.0"
1010 },
1111 "keywords" : [
1212 " css-modules" ,
13+ " typescript" ,
1314 " typings" ,
14- " loader " ,
15- " webpack "
15+ " webpack " ,
16+ " loader "
1617 ],
1718 "license" : " MIT" ,
1819 "homepage" : " https://github.com/Megaputer/dts-css-modules-loader"
You can’t perform that action at this time.
0 commit comments