bufferapp / buffer-js-static-assets

MIT License
0 stars 0 forks source link

Improve library to reduce boilerplate to serve build files #3

Open philippemiguet opened 5 years ago

philippemiguet commented 5 years ago

Purpose

From this discussion, reduce boilerplate for teams who upload the build file using https://github.com/bufferapp/buffer-static-upload.

Example of boilerplate we want to reduce: here

Idea

We can allow to pass a default localHostURL parameter to be used when useLocal is true.

It would result in:

initializeStaticAssetsManagerSync({
  filename: path.join(__dirname, '../staticAssets.json'),
  localHostURL: 'https://local.buffer.com:8080/static/'
})

[...]

fs
    .readFileSync(join(__dirname, 'index.html'), 'utf8')
    .replace('{{{vendor}}}', staticURL('vendor.js')) //https://local.buffer.com:8080/static/vendor.js
    .replace('{{{bundle}}}', staticURL('bundle.js'))
    .replace('{{{bundle-css}}}', staticURL(bundle.css'))
    .replace('{{{stripeScript}}}', stripeScript);
philippemiguet commented 5 years ago

Question

How will it work for serving images from SSR using that same function. It will result in https://local.buffer.com:8080/static/buffer.png.

Dan - If webpack dev server is setup to be a proxy, it will serve the image on the express site.

Phil - When we will work on the next version, we should try to make it work, and have some documentation for the team regarding what config to add to webpack to serve images