File tree Expand file tree Collapse file tree 3 files changed +48
-9
lines changed Expand file tree Collapse file tree 3 files changed +48
-9
lines changed Original file line number Diff line number Diff line change @@ -42,15 +42,26 @@ You can then use it in your templates with a dynamic class binding:
4242</template >
4343```
4444
45- ## Parameters
45+ ## Opt-in Usage
46+
47+ If you only want to use CSS Modules in some of your Vue components, you can set `oneOf` to `true`
48+
49+ ```js
50+ mix.vueCssModules({ oneOf : true });
51+ ```
52+
53+ #### Custom localIdentName
54+
55+ ``` js
56+ // DEFAULT: '[local]_[hash:base64:8]'
57+ mix .vueCssModules ({ localIdentName: " [name]__[local]___[hash:base64:5]" });
58+ ```
59+
60+ #### Local mode
4661
4762``` js
48- // localIdentName: '[local ]_[hash:base64:8]' // default
49- // mode
50- mix.vueCssModules({
51- localIdentName : " [name]__[local]___[hash:base64:5]" ,
52- mode: " local" ,
53- });
63+ // DEFAULT: global
64+ mix .vueCssModules ({ mode: " local" });
5465```
5566
5667## Author
Original file line number Diff line number Diff line change @@ -17,9 +17,11 @@ class VueCssModule {
1717 register ( {
1818 localIdentName = "[local]_[hash:base64:8]" ,
1919 mode = "global" ,
20+ oneOf = false ,
2021 } = { } ) {
2122 this . localIdentName = localIdentName ;
2223 this . mode = mode ;
24+ this . oneOf = oneOf ;
2325 }
2426
2527 /**
@@ -39,7 +41,33 @@ class VueCssModule {
3941 ) ;
4042
4143 if ( loaders != undefined ) {
42- Object . assign ( loaders . options , this [ this . mode ] ( ) ) ;
44+ if ( this . oneOf ) {
45+ const postCssConfig = rule . loaders . find (
46+ ( loader ) => loader . loader === "postcss-loader"
47+ ) ;
48+
49+ delete rule . loaders ;
50+ Object . assign ( rule , {
51+ test : / \. c s s $ / ,
52+ oneOf : [
53+ {
54+ resourceQuery : / m o d u l e / ,
55+ use : [
56+ "style-loader" ,
57+ {
58+ loader : "css-loader" ,
59+ options : this [ this . mode ] ( ) ,
60+ } ,
61+ ] ,
62+ } ,
63+ {
64+ use : [ "style-loader" , postCssConfig ] ,
65+ } ,
66+ ] ,
67+ } ) ;
68+ } else {
69+ Object . assign ( loaders . options , this [ this . mode ] ( ) ) ;
70+ }
4371 }
4472
4573 return rule ;
Original file line number Diff line number Diff line change 11{
22 "name" : " laravel-mix-vue-css-modules" ,
3- "version" : " 1.0.1 " ,
3+ "version" : " 1.0.2 " ,
44 "description" : " A Laravel Mix extension for css modules support." ,
55 "main" : " index.js" ,
66 "scripts" : {
You can’t perform that action at this time.
0 commit comments