packaton 0.0.1 → 0.0.3

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/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface Config {
12
12
 
13
13
  // Production
14
14
  outputPath?: string
15
+ outputExtension?: string
15
16
  minifyJS?: (js: string) => Promise<string>
16
17
  minifyCSS?: (css: string) => Promise<string>
17
18
  minifyHTML?: (html: string) => Promise<string>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "packaton",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "author": "Eric Fortis",
6
6
  "license": "MIT",
package/src/app-prod.js CHANGED
@@ -54,7 +54,7 @@ export async function buildStaticPages(config) {
54
54
  // TODO remap media in css and js
55
55
  await doc.inlineMinifiedCSS()
56
56
  await doc.inlineMinifiedJS()
57
- write(pDist + route, doc.html)
57
+ write(pDist + route + config.outputExtension, doc.html)
58
58
  cspByRoute.push([route, doc.csp()])
59
59
  }
60
60
 
@@ -64,11 +64,18 @@ export async function buildStaticPages(config) {
64
64
  .map(r => `https://${config.sitemapDomain + r}`)
65
65
  .join('\n'))
66
66
 
67
- if (config.cspMapEnabled)
67
+ if (config.cspMapEnabled) {
68
68
  write(pDistCspNginxMap, cspByRoute.map(([route, csp]) =>
69
69
  `${route} "${csp}";`).join('\n'))
70
+
71
+ // cloudflare
72
+ write(pDistMedia + '/_headers', cspByRoute.map(([route, csp]) => {
73
+ const r = route === '/index' ? '/' : route
74
+ return `${r}\n Content-Security-Policy: ${csp}`
75
+ }).join('\n'))
76
+ }
70
77
 
71
- reportSizes(pSizesReport, pDist, docs.routes)
78
+ reportSizes(pSizesReport, pDist, docs.routes.map(f => f + config.outputExtension))
72
79
  }
73
80
  catch (error) {
74
81
  reject(error)
package/src/config.js CHANGED
@@ -26,6 +26,7 @@ const schema = {
26
26
  hotReload: [true, is(Boolean)],
27
27
 
28
28
  // Production
29
+ outputExtension: ['.html', optional(String)],
29
30
  outputPath: ['dist', optional(String)], // TODO resolve
30
31
  minifyJS: [minifyJS, optional(Function)],
31
32
  minifyCSS: [minifyCSS, optional(Function)],
@@ -3,7 +3,7 @@ import { read, sizeOf, sha1, saveAsJSON, isFile } from './fs-utils.js'
3
3
 
4
4
 
5
5
  export function reportSizes(reportFilename, baseDir, files) {
6
- const oldReport = isFile(reportFilename)
6
+ const oldReport = isFile(reportFilename)
7
7
  ? JSON.parse(read(reportFilename))
8
8
  : {}
9
9
  const newReport = {}