Skip to content

Commit

Permalink
GCCによるminifyをデプロイフローに組み込み
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuyoshi-yamazaki committed Sep 13, 2022
1 parent 96de855 commit 0e1da41
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ plugins:
ignorePatterns:
- src/_old/**/*
- src/error_mapper/**/*
- rollup.config.js
- rollup_build.config.js
- rollup_deploy.config.js
- dist/**/*
rules:
indent:
Expand Down
12 changes: 12 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

TEMP_FILE=temp/temp.js

if [ -e TEMP_FILE ]; then
rm TEMP_FILE
fi

yarn rollup -c rollup_build.config.js
java -jar compiler.jar --language_out ECMASCRIPT_2015 --js $TEMP_FILE --js_output_file dist/main.js
yarn rollup -c rollup_deploy.config.js

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"ts-polyfill": "^3.8.2"
},
"scripts": {
"deploy": "rollup -c && echo '\\007'",
"deploy": "./deploy.sh && echo '\\007'",
"test": "jest && echo '\\007'"
},
"jest": {
Expand Down
8 changes: 3 additions & 5 deletions rollup.config.js → rollup_build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import clean from "rollup-plugin-clean";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import typescript from "rollup-plugin-typescript2";
import screeps from "rollup-plugin-screeps";

let cfg;
const dest = process.env.DEST;
Expand All @@ -17,16 +16,15 @@ if (!dest) {
export default {
input: "src/main.ts",
output: {
file: "dist/main.js",
file: "temp/temp.js",
format: "cjs",
sourcemap: true
sourcemap: false
},

plugins: [
clean(),
resolve(),
commonjs(),
typescript({tsconfig: "./tsconfig.json"}),
screeps({config: cfg, dryRun: cfg == null})
typescript({ tsconfig: "./tsconfig.json" })
]
}
24 changes: 24 additions & 0 deletions rollup_deploy.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict";

import screeps from "rollup-plugin-screeps";

let cfg;
const dest = process.env.DEST;
if (!dest) {
console.log("No destination specified - code will be compiled but not uploaded");
} else if ((cfg = require("./screeps")[dest]) == null) {
throw new Error("Invalid upload destination");
}

export default {
input: "dist/main.js",
output: {
file: "dist/main.js",
format: "cjs",
sourcemap: false
},

plugins: [
screeps({config: cfg, dryRun: cfg == null})
]
}
2 changes: 1 addition & 1 deletion submodules/private

0 comments on commit 0e1da41

Please sign in to comment.