Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Commit

Permalink
Merge branch 'move-assets-plugin' of https://github.com/fusionjs/fusi…
Browse files Browse the repository at this point in the history
…on-cli into move-assets-plugin
  • Loading branch information
angus-c committed Mar 19, 2019
2 parents 4966433 + 8000758 commit 96f9c3d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fusion-cli",
"version": "1.18.0",
"version": "1.18.2-alpha.0",
"description": "CLI",
"repository": "fusionjs/fusion-cli",
"bin": {
Expand Down
40 changes: 21 additions & 19 deletions plugins/assets-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,26 @@ import serve from 'koa-static';
export default function(dir /*: string */) {
/* eslint-disable-next-line */
return createPlugin /*:: <AssetsDepsType, AssetsType> */({
middleware: () => {
const {baseAssetPath, env} = getEnv();
// setting defer here tells the `serve` middleware to `await next` first before
// setting the response. This allows composition with user middleware
return mount(
baseAssetPath,
serve(path.resolve(dir, `.fusion/dist/${env}/client`), {
defer: true,
setHeaders: res => {
// $FlowFixMe
middleware: () => {
const {baseAssetPath, env} = getEnv();
// setting defer here tells the `serve` middleware to `await next` first before
// setting the response. This allows composition with user middleware
return mount(
baseAssetPath,
serve(path.resolve(dir, `.fusion/dist/${env}/client`), {
defer: true,
setHeaders: res => {
/* eslint-disable-next-line */
console.log('****', 'assets-plugin response');
if (!module.hot) {
res.setHeader('Cache-Control', 'public, max-age=31536000');
}
res.setHeader('Timing-Allow-Origin', '*');
},
})
);
},
});
// $FlowFixMe
if (!module.hot) {
res.setHeader('Cache-Control', 'public, max-age=31536000');
}
res.setHeader('Timing-Allow-Origin', '*');
},
})
);
},
}
);
}

0 comments on commit 96f9c3d

Please sign in to comment.