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
Prev Previous commit
Next Next commit
Create webpack.common.config.js
  • Loading branch information
mbreining committed Nov 27, 2014
commit 2c9724093499cc144f7341f73d290a66c76b6e16
35 changes: 35 additions & 0 deletions webpack/webpack.common.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Common webpack configuration used by webpack.hot.config and webpack.rails.config.

var path = require("path");

module.exports = {
devtool: "eval-source-map",
context: __dirname, // the project dir
entry: [
"./assets/javascripts/example"
],
// In case you wanted to load jQuery from the CDN, this is how you would do it:
// externals: {
// jquery: "var jQuery"
// },
resolve: {
root: [ path.join(__dirname, "scripts"), path.join(__dirname, "assets/javascripts"),
path.join(__dirname, "assets/stylesheets") ],
extensions: ["", ".webpack.js", ".web.js", ".js", ".jsx", ".scss", ".css", "config.js"]
},
module: {
loaders: [
{ test: require.resolve("react"), loader: "expose?React" },
{ test: /\.jsx$/, loaders: ["react-hot", "es6", "jsx?harmony"] },
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.scss$/, loader: "style!css!sass?outputStyle=expanded&imagePath=/assets/images"},

// the url-loader uses DataUrls.
// the file-loader emits files.
{ 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" }
]
}
};
5 changes: 1 addition & 4 deletions webpack/webpack.hot.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var webpack = require("webpack");
var path = require("path");

module.exports = {
devtool: "eval-source-map",

Expand All @@ -18,10 +19,6 @@ module.exports = {
plugins: [
new webpack.HotModuleReplacementPlugin()
],
// In case you wanted to load jQuery from the CDN, this is how you would do it:
// externals: {
// jquery: "var jQuery"
// },
resolve: {
root: [ path.join(__dirname, "scripts"), path.join(__dirname, "assets/javascripts"),
path.join(__dirname, "assets/stylesheets") ],
Expand Down
22 changes: 15 additions & 7 deletions webpack/webpack.rails.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
filename: railsBundleFile,
path: railsJsAssetsDir
},
// Let's load jQuery from the CDN or rails asset pipeline
// Load jQuery from the CDN or rails asset pipeline
externals: {
jquery: "var jQuery"
},
Expand All @@ -34,20 +34,28 @@ module.exports = {
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"},
{ test: /bootstrap-sass\/assets\/javascripts\//,
loader: 'imports?jQuery=jquery' },
{ test: /\.scss$/,
loader: "style!css!sass?outputStyle=expanded&imagePath=/assets/images"},

// Load Bootstrap's CSS
// Needed for the css-loader when [bootstrap-sass-loader]
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/font-woff" },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/octet-stream" },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=image/svg+xml" },
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&minetype=application/font-woff" },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&minetype=application/octet-stream" },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: "file" },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&minetype=image/svg+xml" },
//{ 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.
{ test: require.resolve("jquery"), loader: "expose?jQuery" },
Expand Down