-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add auto-restarter on code modification for development
- Loading branch information
Showing
19 changed files
with
745 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,5 @@ | |
/root/static/sitemaps | ||
/tidyall.ERR | ||
/var | ||
/root/assets | ||
!/root/assets/.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/usr/bin/env node | ||
"use strict"; | ||
import * as esbuild from 'esbuild' | ||
import { lessLoader } from 'esbuild-plugin-less'; | ||
import fs from 'fs'; | ||
import parseArgs from 'minimist'; | ||
|
||
const config = { | ||
entryPoints: [ | ||
'root/static/js/main.js', | ||
'root/static/less/style.less', | ||
], | ||
assetNames: '[name]-[hash]', | ||
entryNames: '[name]-[hash]', | ||
outdir: 'root/assets', | ||
bundle: true, | ||
sourcemap: true, | ||
metafile: true, | ||
inject: ['root/static/js/inject.js'], | ||
loader: { | ||
'.eot': 'file', | ||
'.svg': 'file', | ||
'.ttf': 'file', | ||
'.woff': 'file', | ||
'.woff2': 'file', | ||
}, | ||
plugins: [ | ||
lessLoader(), | ||
new class { | ||
name = 'metacpan-build'; | ||
|
||
setup(build) { | ||
build.onResolve( | ||
{ filter: /^(shCore|xregexp)$/ }, | ||
args => ({ external: true }), | ||
); | ||
build.onResolve( | ||
{ filter: /^\// }, | ||
args => ({ external: true }), | ||
); | ||
build.onEnd(result => { | ||
const metafile = result.metafile; | ||
if (metafile && metafile.outputs) { | ||
const files = Object.keys(metafile.outputs).sort() | ||
.map(file => file.replace(/^root\/assets\//, '')); | ||
fs.writeFile( | ||
'root/assets/assets.json', | ||
JSON.stringify(files), | ||
'utf8', | ||
(e) => { | ||
if (e) { | ||
console.log(e); | ||
} | ||
} | ||
); | ||
console.log('assets built'); | ||
} | ||
else { | ||
console.log('asset build failure'); | ||
} | ||
}); | ||
} | ||
}, | ||
], | ||
}; | ||
|
||
const args = parseArgs(process.argv, { | ||
boolean: [ | ||
'watch', | ||
'minify', | ||
], | ||
}); | ||
if (args.minify) { | ||
config.minify = true; | ||
} | ||
const ctx = await esbuild.context(config); | ||
if (args.watch) { | ||
await ctx.watch(); | ||
const sig = await new Promise(resolve => { | ||
[ | ||
'SIGTERM', | ||
'SIGQUIT', | ||
'SIGINT', | ||
].map(sig => process.on(sig, resolve)); | ||
}); | ||
process.stderr.write(`Caught signal: ${sig}\n`); | ||
ctx.dispose(); | ||
} | ||
else { | ||
await ctx.rebuild(); | ||
ctx.dispose(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
services: | ||
asset-build: | ||
build: | ||
context: . | ||
target: build-assets | ||
volumes: | ||
- './root:/build/root/' | ||
- 'assets:/build/root/assets/' | ||
command: [ './build-assets.mjs', '--watch' ] | ||
server: | ||
build: | ||
context: . | ||
target: develop | ||
volumes: | ||
- './:/metacpan-web/' | ||
- 'assets:/metacpan-web/root/assets' | ||
- '/metacpan-web/local' | ||
ports: | ||
- "8000:80" | ||
volumes: | ||
assets: |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.