Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for debug and production builds of Monaco JS files #17

Merged
merged 2 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/dist/
/dist-debug/
/dist-prod/
/node_modules/

package-lock.json
2 changes: 1 addition & 1 deletion build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ just install
just build
```

> **NOTE:** This will output the files to the `dist/` directory.
> **NOTE:** This will output the files to the `dist-debug/` and `dist-prod/` directories.
> Use `just build_js` in the root directory to update the files used by the library.
13 changes: 10 additions & 3 deletions build/justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Build the Monaco Javascript files
@build:
-rm dist/*
npm run build
@build: build-debug build-prod

@build-prod:
-rm dist-prod/*
npm run build-prod

@build-debug:
-rm dist-debug/*
npm run build-debug


# Install the node dependencies
@install:
Expand Down
3 changes: 2 additions & 1 deletion build/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"scripts": {
"build": "rollup -c"
"build-prod": "rollup -c",
"build-debug": "rollup -c --configDebug"
},
"dependencies": {
"monaco-editor": "^0.32"
Expand Down
44 changes: 24 additions & 20 deletions build/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { nodeResolve } from "@rollup/plugin-node-resolve";
import styles from "rollup-plugin-styles";
import { terser } from "rollup-plugin-terser";

const commonPlugins = [nodeResolve(), terser()];

const workers = [
{
name: "editor.worker",
Expand All @@ -19,25 +17,31 @@ const workers = [
input: "language/html/html.worker",
},
];
const workerConfigs = workers.map((worker) => ({
input: `monaco-editor/esm/vs/${worker.input}`,
output: {
format: "iife",
file: `dist/${worker.name}.js`,
inlineDynamicImports: true,
},
plugins: [...commonPlugins],
}));

export default [
{
input: "monaco-editor",
export default args => {
const commonPlugins = args.configDebug ? [nodeResolve()] : [nodeResolve(), terser()];
const dist = args.configDebug ? "dist-debug" : "dist-prod";

const workerConfigs = workers.map((worker) => ({
input: `monaco-editor/esm/vs/${worker.input}`,
output: {
format: "es",
file: "dist/editor.js",
format: "iife",
file: `${dist}/${worker.name}.js`,
inlineDynamicImports: true,
},
plugins: [styles(), ...commonPlugins],
},
...workerConfigs,
];
plugins: [...commonPlugins],
}));

return [
{
input: "monaco-editor",
output: {
format: "es",
file: `${dist}/editor.js`,
inlineDynamicImports: true,
},
plugins: [styles(), ...commonPlugins],
},
...workerConfigs,
];
}
Loading