Skip to content

Instantly share code, notes, and snippets.

@brandonb927
Created December 17, 2015 06:29
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonb927/a7724de550bd23646496 to your computer and use it in GitHub Desktop.
Save brandonb927/a7724de550bd23646496 to your computer and use it in GitHub Desktop.
npm scripts ES2015 + babel + react self-contained build
{
...
"devDependencies": {
"autoprefixer": "^6.1.2",
"babel-cli": "^6.3.17",
"babel-plugin-react-transform": "^2.0.0-beta1",
"babel-preset-es2015": "^6.3.13",
"babelify": "^7.2.0",
"bootstrap": "^3.3.6",
"browserify": "^12.0.1",
"eslint": "^1.10.3",
"eslint-watch": "^2.1.4",
"history": "^1.13.1",
"jquery": "^2.1.4",
"livereactload": "^2.1.0",
"postcss-cli": "^2.3.2",
"react": "^0.14.3",
"react-dom": "^0.14.3",
"react-proxy": "^1.1.1",
"react-router": "^1.0.2",
"react-transform-catch-errors": "^1.0.0",
"redbox-react": "^1.2.0",
"rimraf": "^2.4.4",
"uglifyify": "^3.0.1",
"watchify": "^3.6.1"
},
"scripts": {
"clean": "rimraf static/dist",
"make:static_folders": "mkdir -p static/dist/{html,img,css,js/lib}",
"copy": "npm run copy:lib && npm run copy:html && npm run copy:images",
"copy:html": "cp -r static/src/html/* static/dist/html",
"copy:lib": "npm run copy:lib-bootstrap && npm run copy:lib-jquery && npm run build:lib-js",
"copy:lib-bootstrap": "cp -r node_modules/bootstrap/dist/css/{bootstrap.min.css,bootstrap-theme.min.css} static/dist/css && cp -r node_modules/bootstrap/dist/js/bootstrap.min.js static/dist/js/lib",
"copy:lib-jquery": "cp -r node_modules/jquery/dist/jquery.min.js static/dist/js/lib",
"build:lib-js": "cat static/dist/js/lib/jquery.min.js >> static/dist/js/lib.js; echo '\n;' >> static/dist/js/lib.js; cat static/dist/js/lib/bootstrap.min.js >> static/dist/js/lib.js; rimraf static/dist/js/lib",
"copy:images": "cp -r static/src/img/* static/dist/img",
"lint": "npm run lint:js",
"lint:js": "esw static/src/js",
"postcss:build": "postcss --use autoprefixer -b 'last 2 versions' --dir static/dist/css static/src/css/*.css",
"build:js-dev": "BABEL_ENV=development watchify static/src/js/index.js -v -d -p livereactload -o static/dist/js/app.js",
"build:js-prod": "BABEL_ENV=production browserify static/src/js/index.js -v -d | exorcist static/dist/js/app.js.map > static/dist/js/app.js",
"build:dev": "npm run clean && npm run make:static_folders && npm run copy && npm run postcss:build && npm run lint && npm run build:js-dev",
"build:prod": "npm run clean && npm run make:static_folders && npm run copy && npm run postcss:build && npm run lint && npm run build:js-prod"
},
"browserify": {
"transform": [
["babelify", {
"presets": ["es2015", "react"],
"sourceMap": true,
"sourceMapRelative": "."
}]
]
},
"babel": {
"presets": ["es2015", "react"],
"env": {
"development": {
"plugins": [
["react-transform", {
"transforms": [{
"transform": "livereactload/babel-transform",
"imports": ["react"]
}]
}]
]
},
"production": {
"plugins": []
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment