finish integrating npm. move underscore/backbone into npm management (#577)

* finish integrating npm. move underscore/backbone into npm management

* update docs for npm integration

* allow jsx or js extension

* change underscore version
This commit is contained in:
Devin Howard 2016-08-02 03:59:53 +08:00 committed by Connor Turland
parent e6954eb37a
commit 6997142fd9
11 changed files with 41 additions and 2809 deletions

View file

@ -13,8 +13,7 @@
//= require jquery //= require jquery
//= require jquery-ui //= require jquery-ui
//= require jquery_ujs //= require jquery_ujs
//= require ./orderedLibraries/underscore //= require ./webpacked/metamaps.bundle
//= require ./orderedLibraries/backbone
//= require_directory ./lib //= require_directory ./lib
//= require ./src/Metamaps.GlobalUI //= require ./src/Metamaps.GlobalUI
//= require ./src/Metamaps.Router //= require ./src/Metamaps.Router

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -15,9 +15,10 @@ Now install homebrew.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then install nodejs Then install nodejs and frontend code
brew install nodejs brew install nodejs
(cd frontend && npm install && npm run build)
And postgresql: And postgresql:

View file

@ -50,6 +50,12 @@ Install the specific version of ruby needed this will take some time
rvm install $(cat metamaps/.ruby-version) rvm install $(cat metamaps/.ruby-version)
While that is running, you can open another terminal and install the npm frontend code
cd frontend
npm install
npm run build
Now we also need to copy .example-env to a new file named .env. Review the Now we also need to copy .example-env to a new file named .env. Review the
configuration in here to see if you need any changes. configuration in here to see if you need any changes.

View file

@ -20,6 +20,13 @@ Now you are ready to clone the Metamaps git repository:
The third `bundle install` command downloads and installs the rubygem The third `bundle install` command downloads and installs the rubygem
dependencies of Metamaps. dependencies of Metamaps.
You also need to install the Javascript frontend code from the nodejs repositories:
cd frontend
npm install
npm run build
cd ..
At this point you should be in C:\git\metamaps, or whatever equivalent At this point you should be in C:\git\metamaps, or whatever equivalent
directory you've chosen. The next step is to set up your database directory you've chosen. The next step is to set up your database
configuration. From the metamaps directory, run configuration. From the metamaps directory, run

View file

@ -55,12 +55,23 @@ Run this in the metamaps directory, still as metamaps:
# Set up environment variables in your current session # Set up environment variables in your current session
source .env source .env
export RAILS_ENV=production export RAILS_ENV=production
export NODE_ENV=production
# create, load schema, seed # create, load schema, seed
rake db:setup rake db:setup
Now set up nginx - config stored on Linode, including relevant environment #### Install js frontend code
variables.
sudo aptitude install nodejs npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
cd frontend
npm install
npm run build
#### Nginx and SSL
Now set up nginx - config stored on Linode, including relevant
environment variables.
Get an SSL certificate and encrypt it for the realtime video. Get an SSL certificate and encrypt it for the realtime video.
@ -75,8 +86,6 @@ server to see what problems show up:
#### Realtime server: #### Realtime server:
sudo aptitude install nodejs npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo npm install -g forever sudo npm install -g forever
(crontab -u metamaps -l 2>/dev/null; echo "@reboot $(which forever) --append -l /home/metamaps/logs/forever.realtime.log start /home/metamaps/metamaps/realtime/realtime-server.js") | crontab -u metamaps - (crontab -u metamaps -l 2>/dev/null; echo "@reboot $(which forever) --append -l /home/metamaps/logs/forever.realtime.log start /home/metamaps/metamaps/realtime/realtime-server.js") | crontab -u metamaps -

View file

@ -19,9 +19,11 @@ OR
Now that you have the code, run these commands: Now that you have the code, run these commands:
export RAILS_ENV=production export RAILS_ENV=production
export NODE_ENV=production
source .env source .env
bundle install bundle install
(cd frontend && npm install && npm run build)
rake db:migrate rake db:migrate
rake assets:precompile rake assets:precompile
rake perms:fix rake perms:fix

View file

@ -25,11 +25,13 @@
"babel-preset-react": "^6.11.1", "babel-preset-react": "^6.11.1",
"chai": "^3.5.0", "chai": "^3.5.0",
"mocha": "^2.4.5", "mocha": "^2.4.5",
"path": "^0.12.7",
"webpack": "^1.13.1" "webpack": "^1.13.1"
}, },
"dependencies": { "dependencies": {
"backbone": "^1.0.0",
"react": "^15.3.0", "react": "^15.3.0",
"react-dom": "^15.3.0" "react-dom": "^15.3.0",
"requirejs": "^2.1.1",
"underscore": "^1.4.4"
} }
} }

View file

@ -1,11 +1,15 @@
import React from 'react' import React from 'react'
import ReactDOM from 'react-dom' import ReactDOM from 'react-dom'
import ExploreHeader from './components/ExploreHeader.js' import Backbone from 'backbone'
import _ from 'underscore'
import ExploreHeader from './components/ExploreHeader'
// this is optional really, if we import components directly React will be // this is optional really, if we import components directly React will be
// in the bundle, so we won't need a global reference // in the bundle, so we won't need a global reference
window.React = React window.React = React
window.ReactDOM = ReactDOM window.ReactDOM = ReactDOM
window.Backbone = Backbone
window._ = _
window.Metamaps = window.Metamaps || {} window.Metamaps = window.Metamaps || {}
window.Metamaps.ReactComponents = { window.Metamaps.ReactComponents = {

View file

@ -6,7 +6,7 @@ const config = module.exports = {
module: { module: {
loaders: [ loaders: [
{ {
test: /\.js$/, test: /\.(js|jsx)?$/,
exclude: /node_modules/, exclude: /node_modules/,
loaders: [ loaders: [
"babel-loader?cacheDirectory" "babel-loader?cacheDirectory"