Skip to content

Commit

Permalink
tools: add livereload, fix demo target folder
Browse files Browse the repository at this point in the history
  • Loading branch information
luwes committed Oct 3, 2023
1 parent 2c989bc commit 4ceea00
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ package-lock.json
/es6
.idea/
.vscode/
/examples/react/public/index.js
/examples/react/public/index.js.map
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"typings": "lib/index.d.ts",
"scripts": {
"clean": "rimraf lib lazy demo coverage *.d.ts",
"start": "node scripts/build examples/react/src/index.js --format=iife --bundle --outdir=examples/react/public --watch --servedir=examples/react/public",
"start": "cp -r examples/react/public demo & yarn build:lib --watch=forever & node scripts/build examples/react/src/index.js --format=iife --bundle --outdir=demo --watch --servedir=demo --livereload",
"lint": "standard --verbose | snazzy",
"lint:fix": "standard --fix",
"lint:ts": "ts-standard --verbose types/*.d.ts | snazzy",
"lint:ts:fix": "ts-standard --fix types/*.d.ts",
"test": "cross-env NODE_ENV=test ava",
"test:coverage": "cross-env NODE_ENV=test nyc ava",
"test:codecov": "nyc report --reporter=json && codecov -f coverage/coverage-final.json",
"build:demo": "node scripts/build examples/react/src/index.js --format=iife --bundle --outdir=examples/react/public --minify --sourcemap",
"build:demo": "cp -r examples/react/public demo && yarn build:lib && node scripts/build examples/react/src/index.js --format=iife --bundle --outdir=demo --minify --sourcemap",
"build:lib": "node scripts/build src/*.js src/players/*.js --outdir=lib --format=cjs",
"build:lazy": "node scripts/build src/*.js src/players/*.js --outdir=lazy --format=cjs",
"build:dist": "node scripts/build src/index.js --outfile=dist/ReactPlayer.js --format=iife --bundle --minify --sourcemap --global-name=ReactPlayer --external:react --footer:js=\"ReactPlayer = ReactPlayer.default;\"",
Expand Down
6 changes: 5 additions & 1 deletion scripts/build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const { values: args, positionals } = parseArgs({
allowPositionals: true
})

// https://esbuild.github.io/api/#live-reload
const livereloadJs = 'new EventSource(\'/esbuild\').addEventListener(\'change\', () => location.reload());'

const options = {
target: 'es2019',
logLevel: 'info',
Expand All @@ -29,7 +32,8 @@ const options = {
'.svg': 'text'
},
footer: {
js: args['footer:js'] ?? ''
js: (args['footer:js'] ?? '') +
(args.livereload ? `\n${livereloadJs}` : '')
}
}

Expand Down

0 comments on commit 4ceea00

Please sign in to comment.