Skip to content

Commit

Permalink
add dev server (ApoorvSaxena#60)
Browse files Browse the repository at this point in the history
* ✨ add dev server closes ApoorvSaxena#33

* ✨ add watch mode
  • Loading branch information
thiamsantos authored and ApoorvSaxena committed Oct 14, 2017
1 parent 2752b09 commit d392007
Show file tree
Hide file tree
Showing 5 changed files with 1,157 additions and 32 deletions.
18 changes: 15 additions & 3 deletions build.js
Expand Up @@ -3,6 +3,7 @@ const babel = require('rollup-plugin-babel')
const filesize = require('rollup-plugin-filesize')
const uglify = require('rollup-plugin-uglify')
const license = require('rollup-plugin-license')
const chokidar = require('chokidar')

const targets = {
umd: 'dist/lozad.js',
Expand Down Expand Up @@ -57,6 +58,17 @@ function build(format) {
)
}

Promise.all([build('umd'), build('min')]).catch(err => {
console.error(err)
})
function main() {
return Promise.all([build('umd'), build('min')]).catch(err => {
console.error(err)
})
}

main()

if (process.env.NODE_ENV === 'development') {
chokidar.watch('src/**/*.js').on('change', path => {
console.log('CHANGE: ' + path)
main()
})
}
2 changes: 1 addition & 1 deletion dist/lozad.js
@@ -1,4 +1,4 @@
/*! lozad.js - v1.0.8 - 2017-10-13
/*! lozad.js - v1.0.8 - 2017-10-14
* https://github.com/ApoorvSaxena/lozad.js
* Copyright (c) 2017 Apoorv Saxena; Licensed MIT */

Expand Down
2 changes: 1 addition & 1 deletion dist/lozad.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions package.json
Expand Up @@ -6,11 +6,14 @@
"homepage": "https://github.com/ApoorvSaxena/lozad.js",
"scripts": {
"test": "nyc mocha",
"build": "node build.js",
"build": "cross-env NODE_ENV=production node build.js",
"build:watch": "cross-env NODE_ENV=development node build.js",
"prepublish": "npm run build",
"prelint": "prettier --single-quote --no-semi --no-bracket-spacing --trailing-comma none --write \"lib/**/*.js\" --write build.js --write \"test/*.js\"",
"precommit": "npm run lint && npm run build",
"lint": "xo --fix src/*.js build.js test/*.js"
"lint": "xo --fix src/*.js build.js test/*.js",
"serve": "browser-sync start --server \"demo\" --server \".\" --files \"demo\" --files \"dist\" --port 3000",
"dev": "run-p -r serve build:watch"
},
"author": {
"name": "Apoorv Saxena",
Expand Down Expand Up @@ -49,11 +52,15 @@
"babel-core": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-0": "^6.24.1",
"browser-sync": "^2.18.13",
"chokidar": "^1.7.0",
"cross-env": "^5.0.5",
"husky": "^0.14.3",
"jsdom": "^11.2.0",
"jsdom-global": "^3.0.2",
"mocha": "^3.5.1",
"npm-run-all": "^4.1.1",
"nyc": "^11.2.1",
"husky": "^0.14.3",
"prettier": "^1.6.1",
"rollup": "^0.49.2",
"rollup-plugin-babel": "^3.0.2",
Expand Down

0 comments on commit d392007

Please sign in to comment.