tldraw/apps/vscode/editor/scripts/dev.mjs
Gwenaël Gallon e0e1373468
Chore: clean up sort imports with prettier (#870)
* Update prettier to latest

* Add format command

* Create .prettierignore

* Add prettier plugin sort imports

* Update prettier config

* Update prettier config

* Update .prettierignore

* Fix @babel/parser conflict

https://github.com/trivago/prettier-plugin-sort-imports/issues/156

* Revert "Update .prettierignore"

This reverts commit 282e5b838376f16b3df7f4c1f99f1106baaffea4.

* Revert change for apps/www/pages/v/[id].tsx

* Sort imports

Moves the third party imports to the top, "~" imports in middle, and "./" at last

* Sorting of the specifiers

in an import declarations

* [www] use path vs  "../"

* [core] use path "~" vs "../"

* [tldraw] use path "~" vs "../.../"

* [tldraw] use path "~" vs "../"

* [tldraw] Cleanup

* Update prettier config

* Last use path "~" vs "../.../"

* [www] Fix order of the third party imports

* Clean prettier config
2022-08-02 14:56:12 +01:00

61 lines
1.2 KiB
JavaScript

/* eslint-disable no-undef */
import dotenv from 'dotenv'
import esbuildServe from 'esbuild-serve'
import fs from 'fs'
import path from 'path'
dotenv.config()
const { log: jslog } = console
async function main() {
if (fs.existsSync('./dist')) {
fs.rmSync('./dist', { recursive: true }, (e) => {
if (e) {
throw e
}
})
}
if (!fs.existsSync('./dist')) {
fs.mkdirSync('./dist')
}
fs.readdirSync('./src/public').forEach((file) =>
fs.copyFile(path.join('./src/public', file), path.join('./dist', file), (err) => {
if (err) throw err
})
)
try {
await esbuildServe(
{
entryPoints: ['src/index.tsx'],
outfile: 'dist/index.js',
minify: false,
bundle: true,
incremental: true,
target: 'es6',
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
define: {
'process.env.NODE_ENV': '"production"',
},
watch: {
onRebuild(err) {
err ? error('❌ Failed') : jslog('✅ Updated')
},
},
},
{
port: 5420,
root: './dist',
live: true,
}
)
} catch (err) {
process.exit(1)
}
}
main()