Skip to content

Commit

Permalink
Better Webpack configuration
Browse files Browse the repository at this point in the history
 - Remove the extra entry points for running the development server and
   replace them with command line switches in the command for "npm
   start".  This means we're left with a single index.jsx entry point in
   the Webpack configuration, which is almost certainly what we want.

 - Small changes for error free operation in production.

 - Add babel-gettext-extractor plugin to Webpack setup (using Cadasta
   fork of getsentry/babel-gettext-extractor, modified to work with
   Babel 6).
  • Loading branch information
Ian Ross committed Feb 10, 2016
1 parent 93dc995 commit e5ed136
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 6 deletions.
16 changes: 15 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
"test": "./node_modules/.bin/karma start",
"travis-test": "./node_modules/.bin/karma start --single-run",
"lint": "./node_modules/.bin/eslint --ext .js,.jsx 'src/js/**/*.@(js|jsx)'; exit 0",
"start": "./node_modules/.bin/webpack-dev-server"
"start": "./node_modules/.bin/webpack-dev-server --inline --hot"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"autoprefixer-loader": "^3.1.0",
"babel-cli": "^6.5.1",
"babel-core": "^6.3.17",
"babel-eslint": "^4.1.6",
"babel-gettext-extractor": "git://github.com/Cadasta/babel-gettext-extractor.git",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
Expand Down Expand Up @@ -53,6 +55,18 @@
"presets": [
"es2015",
"react"
],
"plugins": [
[
"babel-gettext-extractor", {
"functionNames": {
"t": ["msgid"],
"tn": ["msgid", "msgid_plural", "count"],
"tct": ["msgid"]
},
"baseDirectory": "."
}
]
]
},
"dependencies": {
Expand Down
2 changes: 0 additions & 2 deletions app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ process.argv.forEach(function processCliArgs(arg) {

module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server',
'./src/index.jsx',
],
module: {
Expand Down
5 changes: 4 additions & 1 deletion cadasta/config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@
}

DJOSER.update({
'DOMAIN': 'cadasta.org',
'DOMAIN': os.environ['DOMAIN'],
})

# Adding localhost here for uWSGI debugging!
ALLOWED_HOSTS = [os.environ['API_HOST'], 'localhost']

ADMINS = [('Cadasta platform admins', '[email protected]')]
EMAIL_HOST = 'email-smtp.us-west-2.amazonaws.com'
EMAIL_PORT = 465
EMAIL_USE_SSL = True
EMAIL_HOST_USER = os.environ['EMAIL_HOST_USER']
EMAIL_HOST_PASSWORD = os.environ['EMAIL_HOST_PASSWORD']
SERVER_EMAIL = '[email protected]'
DEFAULT_FROM_EMAIL = '[email protected]'

# Debug logging...
LOGGING = {
Expand Down
4 changes: 2 additions & 2 deletions provision/roles/cadasta/application/templates/settings.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const SETTINGS = {
API_BASE: '{{ api_url }}'
API_BASE: 'http://{{ api_url }}'
};

export default SETTINGS;
export default SETTINGS;
2 changes: 2 additions & 0 deletions provision/roles/cadasta/install/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
block: |
DB_HOST="{{ db_host }}"
API_HOST="{{ api_url }}"
DOMAIN="{{ main_url }}"
SECRET_KEY="{{ secret_key }}"
EMAIL_HOST_USER="{{ email_host_user }}"
EMAIL_HOST_PASSWORD="{{ email_host_password }}"
Expand All @@ -47,6 +48,7 @@
block: |
Defaults env_keep += DB_HOST
Defaults env_keep += API_HOST
Defaults env_keep += DOMAIN
Defaults env_keep += SECRET_KEY
Defaults env_keep += EMAIL_HOST_USER
Defaults env_keep += EMAIL_HOST_PASSWORD
Expand Down
6 changes: 6 additions & 0 deletions provision/roles/cadasta/production/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
command: npm install
chdir="{{ application_path }}app"

- name: Fix node-sass problem
become: yes
become_user: "{{ app_user }}"
command: npm rebuild node-sass
chdir="{{ application_path }}app"

- name: Install npm-run
become: yes
become_user: root
Expand Down
1 change: 1 addition & 0 deletions provision/roles/webserver/production/templates/uwsgi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ daemonize = /var/log/uwsgi/cadasta.log

env = DB_HOST={{ db_host }}
env = API_HOST={{ api_url }}
env = DOMAIN={{ main_url }}
env = SECRET_KEY={{ secret_key }}
env = EMAIL_HOST_USER={{ email_host_user }}
env = EMAIL_HOST_PASSWORD={{ email_host_password }}
Expand Down

0 comments on commit e5ed136

Please sign in to comment.