build: split vendor chunk
This commit is contained in:
parent
901696f8f0
commit
96d15bb480
|
@ -5,8 +5,9 @@ COPY docs/config-docker.yml /root/.salty-dog.yml
|
||||||
|
|
||||||
# copy package first, to invalidate other layers when version changes
|
# copy package first, to invalidate other layers when version changes
|
||||||
COPY package.json /salty-dog/package.json
|
COPY package.json /salty-dog/package.json
|
||||||
|
COPY out/vendor.js /salty-dog/out/vendor.js
|
||||||
|
COPY out/main.js /salty-dog/out/main.js
|
||||||
|
|
||||||
COPY rules /salty-dog/rules
|
COPY rules /salty-dog/rules
|
||||||
COPY out/bundle.js /salty-dog/out/bundle.js
|
|
||||||
|
|
||||||
ENTRYPOINT [ "node", "/salty-dog/out/bundle.js" ]
|
ENTRYPOINT [ "node", "/salty-dog/out/main.js" ]
|
4
Makefile
4
Makefile
|
@ -121,7 +121,7 @@ run-rules: ## validate the rules directory
|
||||||
find $(ROOT_PATH)/rules -maxdepth 1 -name '*.yml' | while read file; \
|
find $(ROOT_PATH)/rules -maxdepth 1 -name '*.yml' | while read file; \
|
||||||
do \
|
do \
|
||||||
echo "Validating $${file}..."; \
|
echo "Validating $${file}..."; \
|
||||||
node out/bundle.js \
|
node out/main.js \
|
||||||
--config-path $(ROOT_PATH)/docs \
|
--config-path $(ROOT_PATH)/docs \
|
||||||
--config-name config-stderr.yml \
|
--config-name config-stderr.yml \
|
||||||
--rules $(ROOT_PATH)/rules/salty-dog.yml \
|
--rules $(ROOT_PATH)/rules/salty-dog.yml \
|
||||||
|
@ -130,7 +130,7 @@ run-rules: ## validate the rules directory
|
||||||
done
|
done
|
||||||
|
|
||||||
run-stream: ## validate stdin and write it to stdout, errors to stderr
|
run-stream: ## validate stdin and write it to stdout, errors to stderr
|
||||||
@node out/bundle.js \
|
@node out/main.js \
|
||||||
--config-path $(ROOT_PATH)/docs \
|
--config-path $(ROOT_PATH)/docs \
|
||||||
--config-name config-stderr.yml \
|
--config-name config-stderr.yml \
|
||||||
--dest - \
|
--dest - \
|
||||||
|
|
|
@ -141,7 +141,7 @@ This project is written in Typescript and requires `node` and `yarn` to build.
|
||||||
> make
|
> make
|
||||||
```
|
```
|
||||||
|
|
||||||
After building, run with: `node out/bundle.js`
|
After building, run with: `node out/main.js`
|
||||||
|
|
||||||
`make` targets are provided for some common arguments:
|
`make` targets are provided for some common arguments:
|
||||||
|
|
||||||
|
|
|
@ -8,24 +8,40 @@ import resolve from 'rollup-plugin-node-resolve';
|
||||||
import typescript from 'rollup-plugin-typescript2';
|
import typescript from 'rollup-plugin-typescript2';
|
||||||
|
|
||||||
const metadata = require('../package.json');
|
const metadata = require('../package.json');
|
||||||
|
const shebang = '#! /usr/bin/env node';
|
||||||
// `npm run build` -> `production` is true
|
const license = fs.readFileSync('LICENSE.md', 'utf-8').split('\n').map(ln => ` * ${ln}`);
|
||||||
// `npm run dev` -> `production` is false
|
|
||||||
const production = !process.env.ROLLUP_WATCH;
|
|
||||||
|
|
||||||
const bundle = {
|
const bundle = {
|
||||||
input: 'src/index.ts',
|
input: [
|
||||||
|
'src/index.ts',
|
||||||
|
'test/harness.ts',
|
||||||
|
'test/**/Test*.ts',
|
||||||
|
],
|
||||||
|
manualChunks(id) {
|
||||||
|
if (id.includes('/node_modules/')) {
|
||||||
|
return 'vendor';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id.includes('/test/')) {
|
||||||
|
return 'test'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id.includes('/src/')) {
|
||||||
|
return 'main';
|
||||||
|
}
|
||||||
|
},
|
||||||
output: {
|
output: {
|
||||||
file: 'out/bundle.js',
|
dir: 'out/',
|
||||||
|
chunkFileNames: '[name].js',
|
||||||
|
entryFileNames: 'index.js',
|
||||||
format: 'cjs',
|
format: 'cjs',
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
banner: () => {
|
banner: () => {
|
||||||
const shebang = '#! /usr/bin/env node';
|
|
||||||
const license = fs.readFileSync('LICENSE.md', 'utf-8').split('\n').map(ln => ` * ${ln}`);
|
|
||||||
return [shebang, '/**', ...license, ' **/'].join('\n');
|
return [shebang, '/**', ...license, ' **/'].join('\n');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
multiEntry(),
|
||||||
json(),
|
json(),
|
||||||
replace({
|
replace({
|
||||||
delimiters: ['{{ ', ' }}'],
|
delimiters: ['{{ ', ' }}'],
|
||||||
|
@ -83,20 +99,4 @@ const bundle = {
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
bundle,
|
bundle,
|
||||||
{
|
];
|
||||||
...bundle,
|
|
||||||
input: [
|
|
||||||
'test/harness.ts',
|
|
||||||
'test/**/Test*.ts',
|
|
||||||
],
|
|
||||||
output: {
|
|
||||||
file: 'out/test.js',
|
|
||||||
format: 'cjs',
|
|
||||||
sourcemap: true,
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
multiEntry(),
|
|
||||||
...bundle.plugins,
|
|
||||||
]
|
|
||||||
},
|
|
||||||
];
|
|
|
@ -2,9 +2,9 @@
|
||||||
"name": "salty-dog",
|
"name": "salty-dog",
|
||||||
"version": "0.4.1",
|
"version": "0.4.1",
|
||||||
"description": "YAML linter, transformer, and validator",
|
"description": "YAML linter, transformer, and validator",
|
||||||
"main": "out/bundle.js",
|
"main": "out/main.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"salty-dog": "out/bundle.js"
|
"salty-dog": "out/main.js"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
"doc": "docs",
|
"doc": "docs",
|
||||||
|
|
Loading…
Reference in New Issue