mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-16 20:48:17 -06:00
feat: add yarn dev watcher script
This commit is contained in:
parent
4913d7ee39
commit
7ce0cdedb0
34
netbox/project-static/develop.js
Normal file
34
netbox/project-static/develop.js
Normal file
@ -0,0 +1,34 @@
|
||||
const { exec, execSync } = require('child_process')
|
||||
const chokidar = require('chokidar')
|
||||
|
||||
const sassWatcher = chokidar.watch('styles/**/*.scss')
|
||||
const tsWatcher = chokidar.watch('src/**/*.ts')
|
||||
|
||||
const collectStatic = (type) => {
|
||||
console.log('bundling...')
|
||||
let args = ""
|
||||
if (type === 'style') args += "--styles"
|
||||
if (type === 'script') args += "--scripts"
|
||||
execSync(`node bundle.js ${args}`)
|
||||
|
||||
console.log('collecting...')
|
||||
exec("../../venv/bin/python3 ../manage.py collectstatic --no-input", (err, stdout, stderr) => {
|
||||
err && console.error(err)
|
||||
stdout && console.log(stdout)
|
||||
stderr && console.log('python err:',stderr)
|
||||
console.log('waiting...')
|
||||
})
|
||||
}
|
||||
|
||||
sassWatcher
|
||||
.on('change', path => {
|
||||
console.log(`Sass file ${path} has changed`)
|
||||
collectStatic('style')
|
||||
})
|
||||
|
||||
tsWatcher
|
||||
.on('change', path => {
|
||||
console.log(`TS file ${path} has changed`)
|
||||
collectStatic('script')
|
||||
})
|
||||
|
@ -8,6 +8,7 @@
|
||||
"netbox-graphiql"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "node develop.js",
|
||||
"bundle": "node bundle.js",
|
||||
"bundle:styles": "node bundle.js --styles",
|
||||
"bundle:scripts": "node bundle.js --scripts",
|
||||
@ -44,6 +45,7 @@
|
||||
"@types/masonry-layout": "^4.2.2",
|
||||
"@typescript-eslint/eslint-plugin": "^4.29.3",
|
||||
"@typescript-eslint/parser": "^4.29.3",
|
||||
"chokidar": "^3.5.2",
|
||||
"esbuild": "^0.12.24",
|
||||
"esbuild-sass-plugin": "^1.5.2",
|
||||
"eslint": "^7.32.0",
|
||||
|
@ -608,7 +608,7 @@ chalk@^4.0.0:
|
||||
ansi-styles "^4.1.0"
|
||||
supports-color "^7.1.0"
|
||||
|
||||
"chokidar@>=3.0.0 <4.0.0":
|
||||
"chokidar@>=3.0.0 <4.0.0", chokidar@^3.5.2:
|
||||
version "3.5.2"
|
||||
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.2.tgz#dba3976fcadb016f66fd365021d91600d01c1e75"
|
||||
integrity sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==
|
||||
|
Loading…
Reference in New Issue
Block a user