@fastly/compute-js-static-publish 6.2.0 → 6.3.0
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/README.md +19 -8
- package/build/cli/commands/init-app.js +1 -1
- package/build/cli/index.js +1 -1
- package/build/util/content-types.d.ts.map +1 -1
- package/build/util/content-types.js +29 -28
- package/package.json +1 -1
- package/resources/webpack.config.js +19 -11
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ npm run deploy
|
|
|
64
64
|
- Content and metadata are available to your application, accessible by files' pre-package file paths.
|
|
65
65
|
- Brotli and Gzip compression.
|
|
66
66
|
- Support for `If-None-Match` and `If-Modified-Since` request headers.
|
|
67
|
-
- Optionally use
|
|
67
|
+
- Optionally use webpack as a module bundler.
|
|
68
68
|
- Selectively serve files from Fastly's [KV Store](#kv-store), or embedded into your Wasm module.
|
|
69
69
|
- Supports loading JavaScript files as code into your Compute application.
|
|
70
70
|
- Presets for several static site generators.
|
|
@@ -391,11 +391,10 @@ And that's it! It should be possible to run this task to clean up once in a whil
|
|
|
391
391
|
|
|
392
392
|
* `contentTypes` - Provide custom content types and/or override them.
|
|
393
393
|
|
|
394
|
-
This tool comes with a set of
|
|
395
|
-
add to and/or override items in the default list.
|
|
396
|
-
|
|
394
|
+
This tool comes with a [default set of content types](./src/util/content-types.ts) defined for many common
|
|
395
|
+
file extensions. This list can be used to add to and/or override items in the default list.
|
|
397
396
|
Content type definitions are checked in the provided order, and if none of them match, the default content types are
|
|
398
|
-
tested
|
|
397
|
+
tested afterward.
|
|
399
398
|
|
|
400
399
|
Provide these as an array of content type definition objects, each with the following keys and values:
|
|
401
400
|
* `test` - a RegExp or function to perform on the asset key. If the test succeeds, then the content asset is considered
|
|
@@ -404,6 +403,18 @@ And that's it! It should be possible to run this task to clean up once in a whil
|
|
|
404
403
|
* `text` - If `true`, this content type definition is considered to contain textual data. This makes `.text()` and `.json()`
|
|
405
404
|
available for calling on store entries. If not specified, this is treated as `false`.
|
|
406
405
|
|
|
406
|
+
For example, to add a custom content type `application/x-custom` for files that have a `.custom` extension, and not treat
|
|
407
|
+
it as a text file, add the following to your `static-publish.rc.js` file:
|
|
408
|
+
|
|
409
|
+
```javascript
|
|
410
|
+
const config = {
|
|
411
|
+
/* ... other config ... */
|
|
412
|
+
contentTypes: [
|
|
413
|
+
{ test: /\.custom$/, contentType: 'application/x-custom', text: false },
|
|
414
|
+
],
|
|
415
|
+
};
|
|
416
|
+
```
|
|
417
|
+
|
|
407
418
|
> Note that content types are tested at publishing time, not at runtime.
|
|
408
419
|
|
|
409
420
|
* `server` - [Configuration of `PublisherServer()`](#configuring-publisherserver).
|
|
@@ -572,10 +583,10 @@ publishing event.
|
|
|
572
583
|
|
|
573
584
|
See the definition of `ContentAssetMetadataMapEntry` in the [`types/content-assets` file](./src/types/content-assets.ts) for more details.
|
|
574
585
|
|
|
575
|
-
### Using
|
|
586
|
+
### Using webpack
|
|
576
587
|
|
|
577
|
-
As of v4,
|
|
578
|
-
If you wish to use some features of
|
|
588
|
+
As of v4, webpack is no longer required, and is no longer part of the default scaffolded application.
|
|
589
|
+
If you wish to use some features of webpack, you may include webpack in your generated application by specifying
|
|
579
590
|
`--webpack` at the command line.
|
|
580
591
|
|
|
581
592
|
## Migrating
|
|
@@ -417,7 +417,7 @@ export function initApp(commandLineValues) {
|
|
|
417
417
|
console.log('KV Store Name :', kvStoreName ?? '(None)');
|
|
418
418
|
console.log('');
|
|
419
419
|
if (useWebpack) {
|
|
420
|
-
console.log('Creating project with
|
|
420
|
+
console.log('Creating project with webpack.');
|
|
421
421
|
console.log('');
|
|
422
422
|
}
|
|
423
423
|
console.log("Initializing Compute Application in " + computeJsDir + "...");
|
package/build/cli/index.js
CHANGED
|
@@ -17,7 +17,7 @@ const optionDefinitions = [
|
|
|
17
17
|
{ name: 'build-static', type: Boolean },
|
|
18
18
|
{ name: 'suppress-framework-warnings', type: Boolean },
|
|
19
19
|
{ name: 'output', alias: 'o', type: String, defaultValue: './compute-js', },
|
|
20
|
-
// Whether the scaffolded project should use
|
|
20
|
+
// Whether the scaffolded project should use webpack to bundle assets.
|
|
21
21
|
{ name: 'webpack', type: Boolean, defaultValue: false },
|
|
22
22
|
// The 'root' directory for the publishing.
|
|
23
23
|
// All assets are expected to exist under this root. Required.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../src/util/content-types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,qBAAqB,EACtB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../src/util/content-types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,qBAAqB,EACtB,MAAM,2BAA2B,CAAC;AAqCnC,wBAAgB,sBAAsB,qBAErC;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,cAAc,EAAE,oBAmD/D;AAED,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,cAAc,EAAE,GAAG,IAAI,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CAcrI"}
|
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
const defaultContentTypes = [
|
|
2
2
|
// Text formats
|
|
3
|
-
{ test:
|
|
4
|
-
{ test:
|
|
5
|
-
{ test:
|
|
6
|
-
{ test:
|
|
7
|
-
{ test:
|
|
8
|
-
{ test:
|
|
9
|
-
{ test:
|
|
10
|
-
{ test:
|
|
3
|
+
{ test: /\.txt$/, contentType: 'text/plain', text: true },
|
|
4
|
+
{ test: /\.htm(l)?$/, contentType: 'text/html', text: true },
|
|
5
|
+
{ test: /\.xml$/, contentType: 'application/xml', text: true },
|
|
6
|
+
{ test: /\.json$/, contentType: 'application/json', text: true },
|
|
7
|
+
{ test: /\.map$/, contentType: 'application/json', text: true },
|
|
8
|
+
{ test: /\.js$/, contentType: 'application/javascript', text: true },
|
|
9
|
+
{ test: /\.css$/, contentType: 'text/css', text: true },
|
|
10
|
+
{ test: /\.svg$/, contentType: 'image/svg+xml', text: true },
|
|
11
11
|
// Binary formats
|
|
12
|
-
{ test:
|
|
13
|
-
{ test:
|
|
14
|
-
{ test:
|
|
15
|
-
{ test:
|
|
16
|
-
{ test:
|
|
17
|
-
{ test:
|
|
18
|
-
{ test:
|
|
19
|
-
{ test:
|
|
20
|
-
{ test:
|
|
21
|
-
{ test:
|
|
22
|
-
{ test:
|
|
23
|
-
{ test:
|
|
24
|
-
{ test:
|
|
25
|
-
{ test:
|
|
26
|
-
{ test:
|
|
27
|
-
{ test:
|
|
28
|
-
{ test:
|
|
29
|
-
{ test:
|
|
30
|
-
{ test:
|
|
31
|
-
{ test:
|
|
12
|
+
{ test: /\.bmp$/, contentType: 'image/bmp', text: false },
|
|
13
|
+
{ test: /\.png$/, contentType: 'image/png', text: false },
|
|
14
|
+
{ test: /\.gif$/, contentType: 'image/gif', text: false },
|
|
15
|
+
{ test: /\.jp(e)?g$/, contentType: 'image/jpeg', text: false },
|
|
16
|
+
{ test: /\.ico$/, contentType: 'image/vnd.microsoft.icon', text: false },
|
|
17
|
+
{ test: /\.tif(f)?$/, contentType: 'image/png', text: false },
|
|
18
|
+
{ test: /\.webp$/, contentType: 'image/webp', text: false },
|
|
19
|
+
{ test: /\.aac$/, contentType: 'audio/aac', text: false },
|
|
20
|
+
{ test: /\.mp3$/, contentType: 'audio/mpeg', text: false },
|
|
21
|
+
{ test: /\.avi$/, contentType: 'video/x-msvideo', text: false },
|
|
22
|
+
{ test: /\.mp4$/, contentType: 'video/mp4', text: false },
|
|
23
|
+
{ test: /\.mpeg$/, contentType: 'video/mpeg', text: false },
|
|
24
|
+
{ test: /\.webm$/, contentType: 'video/webm', text: false },
|
|
25
|
+
{ test: /\.pdf$/, contentType: 'application/pdf', text: false },
|
|
26
|
+
{ test: /\.tar$/, contentType: 'application/x-tar', text: false },
|
|
27
|
+
{ test: /\.zip$/, contentType: 'application/zip', text: false },
|
|
28
|
+
{ test: /\.eot$/, contentType: 'application/vnd.ms-fontobject', text: false },
|
|
29
|
+
{ test: /\.otf$/, contentType: 'font/otf', text: false },
|
|
30
|
+
{ test: /\.ttf$/, contentType: 'font/ttf', text: false },
|
|
31
|
+
{ test: /\.woff$/, contentType: 'font/woff', text: false },
|
|
32
|
+
{ test: /\.woff2$/, contentType: 'font/woff2', text: false },
|
|
32
33
|
];
|
|
33
34
|
export function getDefaultContentTypes() {
|
|
34
35
|
return defaultContentTypes;
|
package/package.json
CHANGED
|
@@ -2,14 +2,18 @@ const path = require("path");
|
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
entry: "./src/index.js",
|
|
5
|
+
target: false,
|
|
6
|
+
devtool: false,
|
|
5
7
|
optimization: {
|
|
6
8
|
minimize: true
|
|
7
9
|
},
|
|
8
|
-
target: "webworker",
|
|
9
10
|
output: {
|
|
10
11
|
filename: "index.js",
|
|
11
12
|
path: path.resolve(__dirname, "bin"),
|
|
12
|
-
|
|
13
|
+
chunkFormat: 'commonjs',
|
|
14
|
+
library: {
|
|
15
|
+
type: 'commonjs',
|
|
16
|
+
},
|
|
13
17
|
},
|
|
14
18
|
module: {
|
|
15
19
|
// Loaders go here.
|
|
@@ -17,17 +21,21 @@ module.exports = {
|
|
|
17
21
|
// rules: [
|
|
18
22
|
// ],
|
|
19
23
|
},
|
|
24
|
+
resolve: {
|
|
25
|
+
conditionNames: [
|
|
26
|
+
'fastly',
|
|
27
|
+
'...',
|
|
28
|
+
],
|
|
29
|
+
},
|
|
20
30
|
plugins: [
|
|
21
|
-
// Polyfills go here
|
|
22
|
-
//
|
|
23
|
-
//
|
|
31
|
+
// Webpack Plugins and Polyfills go here
|
|
32
|
+
// e.g., cross-platform WHATWG or core Node.js modules needed for your application.
|
|
33
|
+
// new webpack.ProvidePlugin({
|
|
34
|
+
// }),
|
|
24
35
|
],
|
|
25
36
|
externals: [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
callback();
|
|
31
|
-
}
|
|
37
|
+
// Allow webpack to handle 'fastly:*' namespaced module imports by treating
|
|
38
|
+
// them as modules rather than trying to process them as URLs
|
|
39
|
+
/^fastly:.*$/,
|
|
32
40
|
],
|
|
33
41
|
};
|