File tree Expand file tree Collapse file tree 4 files changed +30
-6
lines changed Expand file tree Collapse file tree 4 files changed +30
-6
lines changed Original file line number Diff line number Diff line change 1
1
npm-debug.log
2
+ node_modules
Original file line number Diff line number Diff line change 1
1
# typed-css-modules-loader
2
2
3
3
Simplest webpack loader for https://github.com/Quramy/typed-css-modules
4
- Has no configuration atm.
5
4
6
- I suggest using it as preloader. It will generate ` .css.d.ts ` files near the ` .css `
7
- Please take a look at [ this discussion] ( https://github.com/Quramy/typed-css-modules/issues/2 ) to make a decision.
5
+ I suggest using it as preloader. Unless you change the options (see below), it
6
+ will generate ` .css.d.ts ` files near the ` .css ` . Please take a look at
7
+ [ this discussion] ( https://github.com/Quramy/typed-css-modules/issues/2 ) to make a decision.
8
+
9
+ You can affect how ` typed-css-modules ` behaves by using query parameters. The loader
10
+ will pass any query parameters you specify to the constructor of the ` DtsCreator `
11
+ class. For more info on available options, please take a look here:
12
+ [ DtsCreator constructor] ( https://github.com/Quramy/typed-css-modules#new-dtscreatoroption ) .
13
+
8
14
9
15
``` js
10
16
@@ -17,6 +23,8 @@ const settings = {
17
23
test: / \. css$ / ,
18
24
exclude: / node_modules/ ,
19
25
loader: ' typed-css-modules'
26
+ // or in case you want to use parameters:
27
+ // loader: 'typed-css-modules?outDir=/tmp'
20
28
}
21
29
],
22
30
}
Original file line number Diff line number Diff line change 1
1
var DtsCreator = require ( 'typed-css-modules' ) ;
2
-
3
- var creator = new DtsCreator ( ) ;
2
+ var loaderUtils = require ( 'loader-utils' ) ;
3
+ var objectAssign = require ( 'object-assign' ) ;
4
4
5
5
module . exports = function ( source , map ) {
6
6
this . cacheable && this . cacheable ( ) ;
7
7
var callback = this . async ( ) ;
8
-
8
+
9
+ // Pass on query parameters as an options object to the DtsCreator. This lets
10
+ // you change the default options of the DtsCreator and e.g. use a different
11
+ // output folder.
12
+ var queryOptions = loaderUtils . parseQuery ( this . query ) ;
13
+ var options ;
14
+ if ( queryOptions ) {
15
+ options = objectAssign ( { } , queryOptions ) ;
16
+ }
17
+
18
+ var creator = new DtsCreator ( options ) ;
19
+
9
20
// creator.create(..., source) tells the module to operate on the
10
21
// source variable. Check API for more details.
11
22
creator . create ( this . resourcePath , source ) . then ( content => {
Original file line number Diff line number Diff line change 22
22
"license" : " MIT" ,
23
23
"bugs" : {
24
24
"url" : " https://github.com/olegstepura/typed-css-modules-loader/issues"
25
+ },
26
+ "dependencies" : {
27
+ "loader-utils" : " ^0.2.15" ,
28
+ "object-assign" : " ^4.1.0"
25
29
}
26
30
}
You can’t perform that action at this time.
0 commit comments