File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,6 +94,8 @@ module.exports = {
9494};
9595```
9696
97+ ------------------------------------------------------------------------
98+
9799#### ` nameGenerator `
98100
99101Type: ` Function `
@@ -116,6 +118,8 @@ module.exports = {
116118};
117119```
118120
121+ ------------------------------------------------------------------------
122+
119123#### ` requirePattern `
120124
121125Type: ` String `
@@ -135,6 +139,8 @@ module.exports = {
135139};
136140```
137141
142+ ------------------------------------------------------------------------
143+
138144#### `prepareFile`
139145
140146Type: `Function`
@@ -160,3 +166,35 @@ module.exports = {
160166 ],
161167};
162168```
169+
170+ ------------------------------------------------------------------------
171+
172+ #### `libraryEntryGenerator`
173+
174+ Type: `DrupalLibraryEntryGenerator`
175+
176+ Default: `DrupalLibraryEntryGenerator`
177+
178+ Generates a flat Drupal library entry as a javascript object from a `DrupalLibraryMetadata` object.
179+
180+ **webpack.config.js**
181+
182+ ```js
183+ class StaticVersionLibraryGenerator extends DrupalLibraryEntryGenerator {
184+ constructor(version) {
185+ this.version = version
186+ }
187+
188+ async versionGenerator(metadata) {
189+ return this.version
190+ }
191+ }
192+
193+ module.exports = {
194+ plugins: [
195+ new DrupalLibrariesPlugin({
196+ libraryEntryGenerator: new StaticVersionLibraryGenerator(' 2.0 ),
197+ })
198+ ],
199+ };
200+ ```
Original file line number Diff line number Diff line change @@ -19,13 +19,6 @@ class DrupalLibrariesPlugin {
1919 constructor ( opts ) {
2020 opts = opts || { }
2121
22- opts . nameGenerator = opts . nameGenerator || DrupalLibrariesPlugin . defaults . nameGenerator
23- opts . rules = opts . rules || DrupalLibrariesPlugin . defaults . rules
24- opts . libraryEntryGenerator = opts . libraryEntryGenerator || new DrupalLibraryEntryGenerator ( )
25- opts . requirePattern = opts . requirePattern || DrupalLibrariesPlugin . defaults . requirePattern
26-
27- opts . prepareFile = opts . prepareFile || DrupalLibrariesPlugin . defaults . prepareFile
28-
2922 if ( opts . path === false ) {
3023 opts . path = async ( result , metadata ) => { return [ ] }
3124 }
@@ -36,6 +29,14 @@ class DrupalLibrariesPlugin {
3629 }
3730 }
3831
32+ opts . nameGenerator = opts . nameGenerator || DrupalLibrariesPlugin . defaults . nameGenerator
33+ opts . requirePattern = opts . requirePattern || DrupalLibrariesPlugin . defaults . requirePattern
34+ opts . prepareFile = opts . prepareFile || DrupalLibrariesPlugin . defaults . prepareFile
35+ opts . libraryEntryGenerator = opts . libraryEntryGenerator || new DrupalLibraryEntryGenerator ( )
36+
37+ // This is an intentionally undocumented option.
38+ opts . rules = opts . rules || DrupalLibrariesPlugin . defaults . rules
39+
3940 this . opts = opts
4041 this . result = null
4142 }
You can’t perform that action at this time.
0 commit comments