diff --git a/package.json b/package.json index 511bfda..b6c0aab 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "src", "lib", "lib-web", + "scripts", "android", "ios", "cpp", @@ -40,7 +41,7 @@ ], "scripts": { "editor:dev": "vite", - "editor:build": "vite build && node ./scripts/buildEditor.js", + "editor:build": "vite build && node ./scripts/buildEditor.js ./src/simpleWebEditor/build/index.html", "editor:build-web-utils": "rimraf lib-web && vite build --config ./src/webEditorUtils/vite.config.ts && tsc --project ./src/webEditorUtils", "example": "yarn workspace tentap-example", "test": "jest", diff --git a/scripts/buildEditor.js b/scripts/buildEditor.js index 5ceb474..39d86fa 100644 --- a/scripts/buildEditor.js +++ b/scripts/buildEditor.js @@ -3,7 +3,9 @@ const path = require('path'); // This script takes the editor html file and places it into a ts variable // so that it can be imported without the babel-plugin-inline-import plugin -const webDIR = path.resolve(__dirname, '../src/simpleWebEditor'); +const htmlPath = process.argv[2]; +const htmlDir = path.join(htmlPath, '../'); +const editorTsPath = process.argv[3] || path.join(htmlDir, 'editorHtml.ts'); const createContent = (html) => { html = html.replace(/([`$])/g, '\\$1'); @@ -17,10 +19,8 @@ const createContent = (html) => { const build = async () => { try { - const editorPath = path.join(webDIR, 'build/index.html'); - const editorHtml = fs.readFileSync(editorPath, 'utf8'); + const editorHtml = fs.readFileSync(htmlPath, 'utf8'); const editorTs = createContent(editorHtml); - const editorTsPath = path.join(webDIR, 'build/editorHtml.ts'); fs.writeFileSync(editorTsPath, editorTs); console.log('Built Editor!'); } catch (error) {