Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,4 @@ group :development, :test do
gem 'spring'
end


gem 'bootstrap-sass', '~> 3.2.0'
gem 'autoprefixer-rails'

20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ That's totally different than "Live Reload" which refreshes the browser.

# Rails

## Automatically building the rails-bundle.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run this command to automatically build the rails-bundle.js file in the
javascript directory whenever your jsx files change.

```
cd webpack
webpack -w --config webpack.rails.config.js
```

## Run Rails

```
bundle install
rake db:setup
Expand All @@ -47,15 +58,6 @@ Point browser to [http://0.0.0.0:4000]().

It's important to run the rails server on different port than the node server.

## Automatically Building the rails-bundle.js
Run this command to automatically build the rails-bundle.js file in the
javascript directory whenever your jsx files change.

```
cd webpack
webpack -w --config webpack.rails.config.js
```

# Webpack Configuration
`webpack.hot.config.js`: Used by server.js to run the demo server.
`webpack.rails.config.js`: Used to generate the rails-bundle.js file
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@

//= require rails-bundle
//= require turbolinks
//= require bootstrap-sprockets
2 changes: 0 additions & 2 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@import "bootstrap-sprockets";
@import "bootstrap";
@import "../../../webpack/assets/stylesheets/test-stylesheet";
@import "../../../webpack/assets/stylesheets/test-sass-stylesheet";
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"node": "0.10.32"
},
"dependencies": {
"bootstrap-sass": "~3.3.1",
"bootstrap-sass-loader": "~0.0.4",
"imports-loader": "^0.6.3",
"extract-text-webpack-plugin": "~0.3.5",
"body-parser": "^1.9.0",
"bootstrap-webpack": "*",
"es6-loader": "^0.2.0",
Expand Down
23 changes: 20 additions & 3 deletions webpack/webpack.rails.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@ module.exports = {
entry: [
// to expose something Rails specific, uncomment the next line
//"./scripts/rails_only",
"./assets/javascripts/example"
"./assets/javascripts/example",

// Alternative for including everything with no customization
'bootstrap-sass-loader'
//
// Example of using customization file
//'bootstrap-sass!./bootstrap-sass.config.js'
//
// Example of using customization file with ExtractTextPlugin
//"bootstrap-sass!./bootstrap-sass.extract-text-plugin.config.js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should try the ExtractTextPlugin which will make a nice CSS file that can be placed in the asset pipeline. The advantage is that you'll be able to debug the CSS a bit better!

],
output: {
filename: railsBundleFile,
Expand All @@ -28,9 +37,18 @@ module.exports = {
},
module: {
loaders: [
// **IMPORTANT** This is needed so that each bootstrap js file required by
// bootstrap-sass-loader has access to the jQuery object
{ test: /bootstrap-sass\/assets\/javascripts\//, loader: 'imports?jQuery=jquery' },
{ test: /\.scss$/, loader: "style!css!sass?outputStyle=expanded&imagePath=/assets/images"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be sure the different add-ons for bootstrap that were coming from the gem can still be found from the node module.

{ test: /\.woff$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
{ test: /\.ttf$/, loader: "file-loader" },
{ test: /\.eot$/, loader: "file-loader" },
{ test: /\.svg$/, loader: "file-loader" },

{ test: /\.jsx$/, loaders: ['es6', 'jsx?harmony'] },
// Next 2 lines expose jQuery and $ to any JavaScript files loaded after rails-bundle.js
// in the Rails Asset Pipeline. Thus, load this one prior.
// in the Rails Asset Pipeline. Thus, load this one prior.
{ test: require.resolve("jquery"), loader: "expose?jQuery" },
{ test: require.resolve("jquery"), loader: "expose?$" }
]
Expand All @@ -47,4 +65,3 @@ if (devBuild) {
} else {
console.log("Webpack production build for rails");
}