Skip to content

Commit

Permalink
update site script
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Jan 31, 2024
1 parent 4ea1279 commit bbb5fc6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import replaceLink from "./docs-build/remark-replace-link.mjs"
import "./docs-build/setup-docs.mjs"
import path from "path"
import { URL } from "url"
import { version as monacoVersion } from "monaco-editor/package.json"

const dirname = path.dirname(new URL(import.meta.url).pathname)

Expand Down Expand Up @@ -44,6 +45,9 @@ export default defineConfig({
],
},
vite: {
define: {
MONACO_EDITOR_VERSION: JSON.stringify(monacoVersion),
},
server: {
fs: { strict: false },
},
Expand Down
9 changes: 7 additions & 2 deletions docs-build/src/components/eslint/scripts/monaco-loader.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global MONACO_EDITOR_VERSION -- defined */
async function setupMonaco() {
if (typeof window !== "undefined") {
const monacoScript =
Expand All @@ -19,8 +20,12 @@ async function setupMonaco() {
function appendMonacoEditorScript() {
return new Promise((resolve) => {
const script = document.createElement("script")
script.src =
"https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.26.1/min/vs/loader.min.js"

if (typeof MONACO_EDITOR_VERSION !== "undefined") {
script.src = `https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/${MONACO_EDITOR_VERSION}/min/vs/loader.min.js`
} else {
script.src = "https://unpkg.com/monaco-editor@latest/min/vs/loader.js"
}
script.onload = () => {
script.onload = null

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"js-yaml": "^4.1.0",
"less": "^4.1.2",
"mocha": "^10.0.0",
"monaco-editor": "^0.45.0",
"nyc": "^15.1.0",
"pako": "^2.0.4",
"postcss-nested": "^6.0.0",
Expand Down

0 comments on commit bbb5fc6

Please sign in to comment.