swpp-backends 3.1.3 → 3.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.
Files changed (2) hide show
  1. package/dist/swpp/cli.js +11 -1
  2. package/package.json +1 -1
package/dist/swpp/cli.js CHANGED
@@ -123,10 +123,20 @@ async function runBuild(cliJsonPath = './swpp.cli.json', context) {
123
123
  `<script defer src="${cliConfig.domJsPath ?? '/sw-dom.js'}"></script>`;
124
124
  // 修改 html
125
125
  await compilation.compilationEnv.read('PUBLIC_PATH').walkAllFile(async (file) => {
126
- if (!file.absPath.endsWith('.html') || regexes.some(regex => regex.test(file.basePublic)))
126
+ if (!file.basePublic ||
127
+ !file.absPath.endsWith('.html') ||
128
+ regexes.some(regex => regex.test(file.basePublic)))
127
129
  return;
128
130
  const html = await readHtml(compilation, file);
129
131
  const head = html.querySelector('head');
132
+ if (!head) {
133
+ untils_1.utils.printError('跳过 HTML 文件', {
134
+ file: file.basePublic,
135
+ reason: '没有包含 <head> 标签',
136
+ suggestion: '如果该文件无需插入脚本,应通过 excludes 排除;否则至少应包含一个空 <head> 标签'
137
+ });
138
+ return;
139
+ }
130
140
  if (swRegistry)
131
141
  head.insertAdjacentHTML('afterbegin', swRegistry);
132
142
  if (domJsScript)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swpp-backends",
3
- "version": "3.1.3",
3
+ "version": "3.1.4",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "scripts": {