1
0
Fork 0

build: split vendor chunk

This commit is contained in:
ssube 2019-06-29 19:20:50 -05:00
parent 901696f8f0
commit 96d15bb480
5 changed files with 33 additions and 32 deletions

View File

@ -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.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 out/bundle.js /salty-dog/out/bundle.js
ENTRYPOINT [ "node", "/salty-dog/out/bundle.js" ]
ENTRYPOINT [ "node", "/salty-dog/out/main.js" ]

View File

@ -121,7 +121,7 @@ run-rules: ## validate the rules directory
find $(ROOT_PATH)/rules -maxdepth 1 -name '*.yml' | while read file; \
do \
echo "Validating $${file}..."; \
node out/bundle.js \
node out/main.js \
--config-path $(ROOT_PATH)/docs \
--config-name config-stderr.yml \
--rules $(ROOT_PATH)/rules/salty-dog.yml \
@ -130,7 +130,7 @@ run-rules: ## validate the rules directory
done
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-name config-stderr.yml \
--dest - \

View File

@ -141,7 +141,7 @@ This project is written in Typescript and requires `node` and `yarn` to build.
> 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:

View File

@ -8,24 +8,40 @@ import resolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
const metadata = require('../package.json');
// `npm run build` -> `production` is true
// `npm run dev` -> `production` is false
const production = !process.env.ROLLUP_WATCH;
const shebang = '#! /usr/bin/env node';
const license = fs.readFileSync('LICENSE.md', 'utf-8').split('\n').map(ln => ` * ${ln}`);
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: {
file: 'out/bundle.js',
dir: 'out/',
chunkFileNames: '[name].js',
entryFileNames: 'index.js',
format: 'cjs',
sourcemap: true,
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');
},
},
plugins: [
multiEntry(),
json(),
replace({
delimiters: ['{{ ', ' }}'],
@ -83,20 +99,4 @@ const bundle = {
export default [
bundle,
{
...bundle,
input: [
'test/harness.ts',
'test/**/Test*.ts',
],
output: {
file: 'out/test.js',
format: 'cjs',
sourcemap: true,
},
plugins: [
multiEntry(),
...bundle.plugins,
]
},
];
];

View File

@ -2,9 +2,9 @@
"name": "salty-dog",
"version": "0.4.1",
"description": "YAML linter, transformer, and validator",
"main": "out/bundle.js",
"main": "out/main.js",
"bin": {
"salty-dog": "out/bundle.js"
"salty-dog": "out/main.js"
},
"directories": {
"doc": "docs",