Skip to content

Commit

Permalink
Build process alterations
Browse files Browse the repository at this point in the history
- Ensured that "distribution" build puts final product into production mode, mitigating error messages from React and hiding development tool window at launch.
  • Loading branch information
NovaXeros committed May 23, 2017
1 parent 886d73a commit f1caa08
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 7 deletions.
3 changes: 2 additions & 1 deletion app/index.js → app/env-dep/index-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require('babel-register')

const Main = require("./main.js").default
process.env.NODE_ENV = process.env.NODE_ENV || 'development'

process.env.NODE_ENV = 'development'

new Main()
9 changes: 9 additions & 0 deletions app/env-dep/index-prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'

require('babel-register')

const Main = require("./main.js").default

process.env.NODE_ENV = 'production'

new Main()
20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,30 @@
"babel-plugin-transform-async-to-generator": "6.24.1",
"babel-preset-es2015": "6.24.1",
"babel-preset-react": "6.24.1",
"cash-cp":"0.2.0",
"cash-rm": "0.2.0",
"cross-env": "5.0.0",
"electron": "1.6.7",
"electron-builder": "17.8.0",
"electron": "1.6.8",
"electron-builder": "17.10.0",
"jquery": "3.2.1",
"node-sass": "4.5.2",
"webpack": "2.5.1",
"rename": "1.0.4",
"rimraf":"2.6.1",
"webpack": "2.6.0",
"xo": "0.18.2"
},
"scripts": {
"build": "cross-env NODE_ENV=production npm run webpack",
"dev": "npm run webpack",
"build": "npm run prod-set && npm run webpack-prod",
"dev": "npm run webpack-dev",
"dist": "npm run build && npm run sass && build",
"pack": "npm run dev && npm run sass && build --dir",
"postinstall": "install-app-deps",
"sass": "node-sass --include-path sass --output-style compressed sass/base.scss app/dist/bundle.css",
"start": "npm run dev && npm run sass && electron app",
"webpack": "webpack"
"webpack-prod": "webpack --config webpack.config.prod.js",
"webpack-dev": "webpack",
"prod-set": "cross-env NODE_ENV=production && npm run remove-index && cp ./app/env-dep/index-prod.js ./app/index.js",
"dev-set": "cross-env NODE_ENV=development && npm run remove-index && cp ./app/env-dep/index-dev.js ./app/index.js",
"remove-index": "rm ./app/index.js"
}
}
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ module.exports = {
],
target: 'electron'
}

35 changes: 35 additions & 0 deletions webpack.config.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use strict'

let webpack = require('webpack')
let path = require('path')

module.exports = {
devtool: 'hidden-source-map',
entry: path.join(__dirname, 'lib', 'main.js'),
output: {
path: path.join(__dirname, 'app', 'dist'),
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader'
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
],
target: 'electron'
}

0 comments on commit f1caa08

Please sign in to comment.