mirror of
https://github.com/urbit/shrub.git
synced 2025-01-02 01:25:55 +03:00
Merge pull request #3249 from urbit/lf/versioned-js-bundles
interface: do not cache index.html and cache bust JS
This commit is contained in:
commit
b90beaf969
@ -175,14 +175,15 @@ the pill to have the new files/hash. For most things, it is sufficient to run
|
||||
However, if you've made a change to Landscape's JS, then you will need to build
|
||||
a "glob" and upload it to bootstrap.urbit.org. To do this, run `npm install;
|
||||
npm run build:prod` in `pkg/interface`, and add the resulting
|
||||
`pkg/arvo/app/landscape/index.js` to a fakezod at that path (or just create a
|
||||
`pkg/arvo/app/landscape/index.[hash].js` to a fakezod at that path (or just create a
|
||||
new fakezod with `urbit -F zod -B bin/solid.pill -A pkg/arvo`). Run
|
||||
`:glob|make`, and this will output a file in `fakezod/.urb/put/glob-0vXXX.glob`.
|
||||
|
||||
Upload this file to bootstrap.urbit.org, and modify `+hash` at the top of
|
||||
`pkg/arvo/app/glob.hoon` to match the hash in the filename. Do not commit the
|
||||
produced `index.js` and make sure it doesn't end up in your pills (they should
|
||||
be less than 10MB each).
|
||||
`pkg/arvo/app/glob.hoon` to match the hash in the filename of the `.glob` file.
|
||||
Amend `pkg/arvo/app/landscape/index.html` to import the hashed JS bundle, instead
|
||||
of the unversioned index.js. Do not commit the produced `index.js` and
|
||||
make sure it doesn't end up in your pills (they should be less than 10MB each).
|
||||
|
||||
### Tag the resulting commit
|
||||
|
||||
|
@ -7,17 +7,20 @@
|
||||
$% [%clay =path]
|
||||
[%glob =glob:glob]
|
||||
==
|
||||
+$ state-1
|
||||
$: %1
|
||||
=configuration:srv
|
||||
+$ state-base
|
||||
$: =configuration:srv
|
||||
=serving
|
||||
==
|
||||
+$ state-2
|
||||
$: %2
|
||||
state-base
|
||||
==
|
||||
--
|
||||
::
|
||||
%+ verb |
|
||||
%- agent:dbug
|
||||
::
|
||||
=| state-1
|
||||
=| state-2
|
||||
=* state -
|
||||
^- agent:gall
|
||||
|_ =bowl:gall
|
||||
@ -60,12 +63,18 @@
|
||||
^- [content ?]
|
||||
[[%clay clay-path] public]
|
||||
==
|
||||
?> ?=(%1 -.old-state)
|
||||
=? old-state ?=(%1 -.old-state)
|
||||
%= old-state
|
||||
- %2
|
||||
serving (~(del by serving.old-state) /'~landscape'/js/index)
|
||||
==
|
||||
?> ?=(%2 -.old-state)
|
||||
[~ this(state old-state)]
|
||||
::
|
||||
+$ versioned-state
|
||||
$% state-1
|
||||
state-0
|
||||
$% state-0
|
||||
state-1
|
||||
state-2
|
||||
==
|
||||
::
|
||||
+$ serving-0 (map url-base=path [=clay=path public=?])
|
||||
@ -74,6 +83,10 @@
|
||||
=configuration:srv
|
||||
=serving-0
|
||||
==
|
||||
+$ state-1
|
||||
$: %1
|
||||
state-base
|
||||
==
|
||||
--
|
||||
::
|
||||
++ on-poke
|
||||
@ -169,7 +182,7 @@
|
||||
?~ content [not-found:gen %.n]
|
||||
?- -.content.u.content
|
||||
%clay
|
||||
=/ scry-path
|
||||
=/ scry-path=path
|
||||
:* (scot %p our.bowl)
|
||||
q.byk.bowl
|
||||
(scot %da now.bowl)
|
||||
@ -179,10 +192,16 @@
|
||||
=/ file (as-octs:mimes:html .^(@ %cx scry-path))
|
||||
:_ public.u.content
|
||||
?+ ext.req-line not-found:gen
|
||||
[~ %html] (html-response:gen file)
|
||||
[~ %js] (js-response:gen file)
|
||||
[~ %css] (css-response:gen file)
|
||||
[~ %png] (png-response:gen file)
|
||||
::
|
||||
[~ %html]
|
||||
%. file
|
||||
%* . html-response:gen
|
||||
cache
|
||||
!=(/app/landscape/index/html (slag 3 scry-path))
|
||||
==
|
||||
==
|
||||
::
|
||||
%glob
|
||||
|
@ -1,7 +1,7 @@
|
||||
/- glob
|
||||
/+ default-agent, verb, dbug
|
||||
|%
|
||||
++ hash 0v3.cus8h.vc64c.rfb3t.22oji.b529a
|
||||
++ hash 0v2.ssh1k.1s91p.s70g6.j21r5.hr9lc
|
||||
+$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))]
|
||||
+$ all-states
|
||||
$% state-0
|
||||
@ -41,7 +41,7 @@
|
||||
--
|
||||
=| state=state-0
|
||||
=. hash.state hash
|
||||
=/ serve-path=path /'~landscape'/js/index
|
||||
=/ serve-path=path /'~landscape'/js/bundle
|
||||
^- agent:gall
|
||||
%+ verb |
|
||||
%- agent:dbug
|
||||
@ -82,9 +82,19 @@
|
||||
:_ this
|
||||
=/ home=path /(scot %p our.bowl)/home/(scot %da now.bowl)
|
||||
=+ .^(=tube:clay %cc (weld home /js/mime))
|
||||
=+ .^(js=@t %cx (weld home /app/landscape/js/index/js))
|
||||
=+ .^(arch %cy (weld home /app/landscape/js/bundle))
|
||||
=/ bundle=path
|
||||
%- need
|
||||
^- (unit path)
|
||||
%- ~(rep by dir)
|
||||
|= [[file=@t ~] out=(unit path)]
|
||||
?^ out out
|
||||
?. =((end 3 5 file) 'index')
|
||||
~
|
||||
`/[file]/js
|
||||
=+ .^(js=@t %cx :(weld home /app/landscape/js/bundle bundle))
|
||||
=+ !<(=mime (tube !>(js)))
|
||||
=/ =glob:glob (~(put by *glob:glob) /js mime)
|
||||
=/ =glob:glob (~(put by *glob:glob) bundle mime)
|
||||
=/ =path /(cat 3 'glob-' (scot %uv (sham glob)))/glob
|
||||
[%pass /make %agent [our.bowl %hood] %poke %drum-put !>([path (jam glob)])]~
|
||||
::
|
||||
|
@ -23,7 +23,7 @@
|
||||
<div id="root"/>
|
||||
<script src="/~landscape/js/channel.js"></script>
|
||||
<script src="/~landscape/js/session.js"></script>
|
||||
<script src="/~landscape/js/index.js"></script>
|
||||
<script src="/~landscape/js/bundle/index.4257dcef75bd12c7c419.js"></script>
|
||||
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -80,9 +80,11 @@
|
||||
++ max-1-wk ['cache-control' 'max-age=604800']
|
||||
::
|
||||
++ html-response
|
||||
=| cache=?
|
||||
|= =octs
|
||||
^- simple-payload:http
|
||||
[[200 [['content-type' 'text/html'] max-1-wk ~]] `octs]
|
||||
:_ `octs
|
||||
[200 [['content-type' 'text/html'] ?:(cache [max-1-wk ~] ~)]]
|
||||
::
|
||||
++ js-response
|
||||
|= =octs
|
||||
|
@ -52,7 +52,7 @@ if(urbitrc.URL) {
|
||||
...devServer,
|
||||
index: '',
|
||||
proxy: {
|
||||
'/~landscape/js/index.js': {
|
||||
'/~landscape/js/bundle/index.*.js': {
|
||||
target: 'http://localhost:9000',
|
||||
pathRewrite: (req, path) => '/index.js'
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
const path = require('path');
|
||||
// const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
// const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
|
||||
module.exports = {
|
||||
mode: 'production',
|
||||
@ -49,17 +49,16 @@ module.exports = {
|
||||
// historyApiFallback: true
|
||||
// },
|
||||
plugins: [
|
||||
// new CleanWebpackPlugin(),
|
||||
new CleanWebpackPlugin(),
|
||||
// new HtmlWebpackPlugin({
|
||||
// title: 'Hot Module Replacement',
|
||||
// template: './public/index.html',
|
||||
// }),
|
||||
],
|
||||
output: {
|
||||
filename: 'index.js',
|
||||
chunkFilename: 'index.js',
|
||||
path: path.resolve(__dirname, '../../arvo/app/landscape/js'),
|
||||
publicPath: '/'
|
||||
filename: 'index.[contenthash].js',
|
||||
path: path.resolve(__dirname, '../../arvo/app/landscape/js/bundle'),
|
||||
publicPath: '/',
|
||||
},
|
||||
optimization: {
|
||||
minimize: true,
|
||||
|
Loading…
Reference in New Issue
Block a user