@caweb/html-webpack-plugin 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/index.js +58 -58
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
|
@@ -117,7 +117,7 @@ class CAWebHTMLPlugin extends HtmlWebpackPlugin{
|
|
|
117
117
|
Author: "CAWebPublishing",
|
|
118
118
|
Description: "State of California",
|
|
119
119
|
Keywords: "CAWebPublishing, California, government",
|
|
120
|
-
viewport: "width=device-width, initial-scale=1.0, maximum-scale=2.0"
|
|
120
|
+
viewport: "width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=2.0"
|
|
121
121
|
},
|
|
122
122
|
|
|
123
123
|
// array of additional assets to include
|
|
@@ -213,29 +213,29 @@ class CAWebHTMLPlugin extends HtmlWebpackPlugin{
|
|
|
213
213
|
({html, outputName, plugin}, cb) => {
|
|
214
214
|
// if the html contains local assets those assets are added to the options.assets array
|
|
215
215
|
// and the assets are added to the compilation afterEmit
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
216
|
+
let srcHrefAssets = processAssets(html.match(/(src|href)="(.+)"/g));
|
|
217
|
+
let styleAssets = processAssets(html.match(/style=".*url\((\S+)\)/g));
|
|
218
|
+
let allAssets = [ ...new Set([
|
|
219
|
+
...srcHrefAssets,
|
|
220
|
+
...styleAssets
|
|
221
|
+
])
|
|
222
|
+
];
|
|
223
|
+
|
|
224
|
+
allAssets.forEach( asset =>{
|
|
225
|
+
let localFile = asset.startsWith('/') || asset.startsWith('\\') ?
|
|
226
|
+
path.join( appPath, asset ) :
|
|
227
|
+
asset;
|
|
228
|
+
|
|
229
|
+
// if the asset is a local file
|
|
230
|
+
// if the asset is not already in the options.assets array
|
|
231
|
+
if(
|
|
232
|
+
fs.existsSync(localFile) &&
|
|
233
|
+
fs.lstatSync(localFile).isFile() &&
|
|
234
|
+
! this.options.assets.includes(localFile)
|
|
235
|
+
){
|
|
236
|
+
this.options.assets.push(localFile);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
239
|
|
|
240
240
|
// Tell webpack to move on
|
|
241
241
|
cb(null, {html, outputName, plugin});
|
|
@@ -248,41 +248,41 @@ class CAWebHTMLPlugin extends HtmlWebpackPlugin{
|
|
|
248
248
|
|
|
249
249
|
// if there are any assets in the options.assets array
|
|
250
250
|
// we add them to the compilation and emit them
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
251
|
+
this.options.assets.forEach( async (asset) => {
|
|
252
|
+
compilation.fileDependencies.add( asset );
|
|
253
|
+
|
|
254
|
+
// we remove the appPath from the asset path
|
|
255
|
+
// we remove the node_modules/@ from the asset path
|
|
256
|
+
compilation.emitAsset(
|
|
257
|
+
asset.replace(appPath, '').replace(/[\\\/]?node_modules[\\\/@]+/g, ''),
|
|
258
|
+
new compiler.webpack.sources.RawSource( fs.readFileSync(asset) )
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
// if the asset is the @caweb/icon-library font-only.css file we have to also add the font files
|
|
262
|
+
if( asset.match(/@caweb\/icon-library\/build\/font-only-?.*.css/g) ){
|
|
263
|
+
let fontPath = path.join( iconLibraryPath, 'build', 'fonts' );
|
|
264
|
+
|
|
265
|
+
let fontFiles = fs.readdirSync(fontPath).filter( (file) => {
|
|
266
|
+
return file.endsWith('.woff') ||
|
|
267
|
+
file.endsWith('.woff2') ||
|
|
268
|
+
file.endsWith('.eot') ||
|
|
269
|
+
file.endsWith('.svg') ||
|
|
270
|
+
file.endsWith('.ttf');
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
fontFiles.forEach( (file) => {
|
|
274
|
+
compilation.fileDependencies.add( file );
|
|
275
|
+
|
|
276
|
+
let filePath = path.join( fontPath, file );
|
|
277
277
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
278
|
+
// we remove the appPath from the asset path
|
|
279
|
+
compilation.emitAsset(
|
|
280
|
+
filePath.replace(appPath, '').replace(/[\\\/]?node_modules[\\\/@]+/g, ''),
|
|
281
|
+
new compiler.webpack.sources.RawSource( fs.readFileSync(filePath) )
|
|
282
|
+
);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
286
|
|
|
287
287
|
// Tell webpack to move on
|
|
288
288
|
cb(null, {outputName, plugin});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/html-webpack-plugin",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "CAWebPublishing Site Generation HTML Webpack Plugin",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@caweb/framework": "^1.9.
|
|
28
|
+
"@caweb/framework": "^1.9.8",
|
|
29
29
|
"@caweb/icon-library": "^1.1.7",
|
|
30
|
-
"@caweb/template": "^1.0.
|
|
30
|
+
"@caweb/template": "^1.0.14",
|
|
31
31
|
"html-webpack-plugin": "^5.6.6"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|