Skip to content

Commit

Permalink
Add npm script to allow a secondary configuration file to build
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiko Naito committed Aug 31, 2017
1 parent f85b685 commit b6bf8d5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"globals": {
"__DEV__": false,
"__ENV__": false,
"__REDUX_DEV__": false
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ npm-debug.log

# Application specific
src/constants/configurations.production.yml
src/constants/configurations.staging.yml
src/constants/configurations.development.yml
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "src/main.jsx",
"scripts": {
"build": "better-npm-run build",
"build:staging": "better-npm-run build:staging",
"build:dev": "better-npm-run build:dev",
"start": "better-npm-run start",
"test": "echo \"Error: no test specified\" && exit 1",
Expand All @@ -17,6 +18,12 @@
"NODE_ENV": "production"
}
},
"build:staging": {
"command": "webpack",
"env": {
"NODE_ENV": "staging"
}
},
"build:dev": {
"command": "webpack",
"env": {
Expand Down
7 changes: 5 additions & 2 deletions src/constants/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const PROD_CONFIG = (__ENV__ === 'production') ?
require('./configurations.production.yml') :
require('./configurations.staging.yml');

const CONFIG = (__DEV__) ?
require('./configurations.development.yml') :
require('./configurations.production.yml');
require('./configurations.development.yml') : PROD_CONFIG;

// load local visualizations configurations
const USER_CONFIGURABLE_OPTIONS = (__DEV__) ?
Expand Down
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

const __ENV__ = process.env.NODE_ENV || 'development';
const __PROD__ = __ENV__ === 'production';
const __PROD__ = __ENV__ !== 'development';
const __DEV__ = __ENV__ === 'development';
const __REDUX_DEV__ = __DEV__; // && false;

Expand Down Expand Up @@ -80,6 +80,7 @@ const webpackConfig = {
'process.env': {
NODE_ENV: JSON.stringify(__ENV__)
},
__ENV__: JSON.stringify(__ENV__),
__DEV__: JSON.stringify(__DEV__),
__REDUX_DEV__: JSON.stringify(__REDUX_DEV__)
}),
Expand Down

0 comments on commit b6bf8d5

Please sign in to comment.