Skip to content

Commit

Permalink
Merge pull request #30 from 10play/export-scripts
Browse files Browse the repository at this point in the history
Export Build Script
  • Loading branch information
17Amir17 committed Feb 8, 2024
2 parents 389dd95 + 9c3391e commit d443831
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"src",
"lib",
"lib-web",
"scripts",
"android",
"ios",
"cpp",
Expand All @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions scripts/buildEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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) {
Expand Down

0 comments on commit d443831

Please sign in to comment.