@caweb/html-webpack-plugin 1.8.2 → 1.8.5
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 +11 -1
- package/index.js +40 -17
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
v1.8.5
|
|
2
|
+
- Updated npm packages
|
|
3
|
+
|
|
4
|
+
v1.8.4
|
|
5
|
+
- Meta is now passed to templateParameters and removed from top level, the html-webpack-plugin meta tags are missing the self closing forward slash
|
|
6
|
+
- Media that's applied via style attributes using the url function are now emitted to the output directory as well
|
|
7
|
+
|
|
8
|
+
v1.8.3
|
|
9
|
+
- Updated npm packages
|
|
10
|
+
|
|
1
11
|
v1.8.2
|
|
2
|
-
-
|
|
12
|
+
- If the @caweb/icon-library css is used the font files are also moved to the build folder
|
|
3
13
|
|
|
4
14
|
v1.8.1
|
|
5
15
|
- Updated npm packages
|
package/index.js
CHANGED
|
@@ -43,16 +43,16 @@ class CAWebHtmlWebpackPlugin extends HtmlWebpackPlugin{
|
|
|
43
43
|
inject: 'body',
|
|
44
44
|
template: path.join( templatePath, 'patterns', 'index.html'),
|
|
45
45
|
scriptLoading: 'blocking',
|
|
46
|
-
meta: {
|
|
47
|
-
"Author": "CAWebPublishing",
|
|
48
|
-
"Description": "State of California",
|
|
49
|
-
"Keywords": "California,government",
|
|
50
|
-
"viewport": "width=device-width, initial-scale=1.0, maximum-scale=2.0"
|
|
51
|
-
},
|
|
52
46
|
templateParameters: {
|
|
53
47
|
"template": "index",
|
|
54
48
|
"title": path.basename( appPath ),
|
|
55
49
|
"scheme": "oceanside",
|
|
50
|
+
"meta": {
|
|
51
|
+
"Author": "CAWebPublishing",
|
|
52
|
+
"Description": "State of California",
|
|
53
|
+
"Keywords": "California,government",
|
|
54
|
+
"viewport": "width=device-width, initial-scale=1.0, maximum-scale=2.0"
|
|
55
|
+
}
|
|
56
56
|
},
|
|
57
57
|
assets: []
|
|
58
58
|
}
|
|
@@ -103,6 +103,17 @@ class CAWebHtmlWebpackPlugin extends HtmlWebpackPlugin{
|
|
|
103
103
|
defaultOptions.templateParameters.template = template;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
// if the user options has meta tags we merge them with the defaultOptions.templateParameters.meta
|
|
107
|
+
// and clear the meta key
|
|
108
|
+
if( opts.meta ){
|
|
109
|
+
defaultOptions.templateParameters.meta = {
|
|
110
|
+
...defaultOptions.templateParameters.meta,
|
|
111
|
+
...opts.meta
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
delete opts.meta;
|
|
115
|
+
}
|
|
116
|
+
|
|
106
117
|
// if there is a caweb.json file we merge the site data with the templateParameters
|
|
107
118
|
if( fs.existsSync( path.join(appPath, 'caweb.json') ) ){
|
|
108
119
|
|
|
@@ -145,17 +156,30 @@ class CAWebHtmlWebpackPlugin extends HtmlWebpackPlugin{
|
|
|
145
156
|
({html, outputName, plugin}, cb) => {
|
|
146
157
|
// if the html contains local assets those assets are added to the options.assets array
|
|
147
158
|
// and the assets are added to the compilation afterEmit
|
|
148
|
-
let
|
|
159
|
+
let srcHrefAssets = html.match(/(src|href)="(.+?)"/g);
|
|
160
|
+
let styleAssets = html.match(/style=".*url\((\S+)\)/g);
|
|
161
|
+
|
|
162
|
+
let allAssets = [];
|
|
149
163
|
|
|
150
|
-
if(
|
|
151
|
-
|
|
152
|
-
|
|
164
|
+
// if the html contains url() in the style attributes
|
|
165
|
+
if( styleAssets ){
|
|
166
|
+
styleAssets = styleAssets.map( s => s.replace(/(style=".*url\(|["'()])/g, '') )
|
|
167
|
+
// |["'\(\)]
|
|
168
|
+
allAssets = [...allAssets, ...styleAssets];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// if the html contains src or href attributes
|
|
172
|
+
if( srcHrefAssets ){
|
|
173
|
+
srcHrefAssets = srcHrefAssets.map( s => s.replace(/(src|href|=|")/g, '') );
|
|
174
|
+
|
|
175
|
+
allAssets = [...allAssets, ...srcHrefAssets];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
allAssets.forEach( asset =>{
|
|
179
|
+
let localFile = asset.startsWith('/') || asset.startsWith('\\') ?
|
|
180
|
+
path.join( appPath, asset ) :
|
|
181
|
+
asset;
|
|
153
182
|
|
|
154
|
-
|
|
155
|
-
let localFile = ref.startsWith('/') || ref.startsWith('\\') ?
|
|
156
|
-
path.join( appPath, ref ) :
|
|
157
|
-
ref;
|
|
158
|
-
|
|
159
183
|
// if the asset is a local file
|
|
160
184
|
// if the asset is not already in the options.assets array
|
|
161
185
|
if(
|
|
@@ -165,13 +189,12 @@ class CAWebHtmlWebpackPlugin extends HtmlWebpackPlugin{
|
|
|
165
189
|
){
|
|
166
190
|
this.options.assets.push(localFile);
|
|
167
191
|
}
|
|
168
|
-
|
|
192
|
+
});
|
|
169
193
|
|
|
170
194
|
// any references to the node_modules directory are removed
|
|
171
195
|
// any organizational packages @ are also removed
|
|
172
196
|
// this might cause some conflicts with packages that are named the same as organiazational packages
|
|
173
197
|
html = html.replace(/[\\\/]?node_modules[\\\/@]+/g, '/');
|
|
174
|
-
}
|
|
175
198
|
|
|
176
199
|
// Tell webpack to move on
|
|
177
200
|
cb(null, {html, outputName, plugin});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/html-webpack-plugin",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.5",
|
|
4
4
|
"description": "CAWebPublishing Site Generation HTML Webpack Plugin",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/CAWebPublishing/webpack/plugins/html#readme",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@caweb/template": "^1.0.0
|
|
32
|
+
"@caweb/template": "^1.0.0",
|
|
33
33
|
"html-webpack-plugin": "^5.6.3",
|
|
34
|
-
"webpack": "^5.99.
|
|
34
|
+
"webpack": "^5.99.9",
|
|
35
35
|
"webpack-cli": "^6.0.1"
|
|
36
36
|
}
|
|
37
37
|
}
|