Skip to content

Commit 2c97240

Browse files
committed
Create webpack.common.config.js
1 parent 3856dc8 commit 2c97240

File tree

3 files changed

+51
-11
lines changed

3 files changed

+51
-11
lines changed

webpack/webpack.common.config.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Common webpack configuration used by webpack.hot.config and webpack.rails.config.
2+
3+
var path = require("path");
4+
5+
module.exports = {
6+
devtool: "eval-source-map",
7+
context: __dirname, // the project dir
8+
entry: [
9+
"./assets/javascripts/example"
10+
],
11+
// In case you wanted to load jQuery from the CDN, this is how you would do it:
12+
// externals: {
13+
// jquery: "var jQuery"
14+
// },
15+
resolve: {
16+
root: [ path.join(__dirname, "scripts"), path.join(__dirname, "assets/javascripts"),
17+
path.join(__dirname, "assets/stylesheets") ],
18+
extensions: ["", ".webpack.js", ".web.js", ".js", ".jsx", ".scss", ".css", "config.js"]
19+
},
20+
module: {
21+
loaders: [
22+
{ test: require.resolve("react"), loader: "expose?React" },
23+
{ test: /\.jsx$/, loaders: ["react-hot", "es6", "jsx?harmony"] },
24+
{ test: /\.css$/, loader: "style-loader!css-loader" },
25+
{ test: /\.scss$/, loader: "style!css!sass?outputStyle=expanded&imagePath=/assets/images"},
26+
27+
// the url-loader uses DataUrls.
28+
// the file-loader emits files.
29+
{ test: /\.woff$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
30+
{ test: /\.ttf$/, loader: "file-loader" },
31+
{ test: /\.eot$/, loader: "file-loader" },
32+
{ test: /\.svg$/, loader: "file-loader" }
33+
]
34+
}
35+
};

webpack/webpack.hot.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var webpack = require("webpack");
22
var path = require("path");
3+
34
module.exports = {
45
devtool: "eval-source-map",
56

@@ -18,10 +19,6 @@ module.exports = {
1819
plugins: [
1920
new webpack.HotModuleReplacementPlugin()
2021
],
21-
// In case you wanted to load jQuery from the CDN, this is how you would do it:
22-
// externals: {
23-
// jquery: "var jQuery"
24-
// },
2522
resolve: {
2623
root: [ path.join(__dirname, "scripts"), path.join(__dirname, "assets/javascripts"),
2724
path.join(__dirname, "assets/stylesheets") ],

webpack/webpack.rails.config.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
filename: railsBundleFile,
2323
path: railsJsAssetsDir
2424
},
25-
// Let's load jQuery from the CDN or rails asset pipeline
25+
// Load jQuery from the CDN or rails asset pipeline
2626
externals: {
2727
jquery: "var jQuery"
2828
},
@@ -34,20 +34,28 @@ module.exports = {
3434
loaders: [
3535
// **IMPORTANT** This is needed so that each bootstrap js file required by
3636
// bootstrap-sass-loader has access to the jQuery object
37-
{ test: /bootstrap-sass\/assets\/javascripts\//, loader: 'imports?jQuery=jquery' },
38-
{ test: /\.scss$/, loader: "style!css!sass?outputStyle=expanded&imagePath=/assets/images"},
37+
{ test: /bootstrap-sass\/assets\/javascripts\//,
38+
loader: 'imports?jQuery=jquery' },
39+
{ test: /\.scss$/,
40+
loader: "style!css!sass?outputStyle=expanded&imagePath=/assets/images"},
41+
3942
// Load Bootstrap's CSS
4043
// Needed for the css-loader when [bootstrap-sass-loader]
41-
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/font-woff" },
42-
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/octet-stream" },
43-
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
44-
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=image/svg+xml" },
44+
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
45+
loader: "url?limit=10000&minetype=application/font-woff" },
46+
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
47+
loader: "url?limit=10000&minetype=application/octet-stream" },
48+
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
49+
loader: "file" },
50+
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
51+
loader: "url?limit=10000&minetype=image/svg+xml" },
4552
//{ test: /\.woff$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
4653
//{ test: /\.ttf$/, loader: "file-loader" },
4754
//{ test: /\.eot$/, loader: "file-loader" },
4855
//{ test: /\.svg$/, loader: "file-loader" },
4956

5057
{ test: /\.jsx$/, loaders: ['es6', 'jsx?harmony'] },
58+
5159
// Next 2 lines expose jQuery and $ to any JavaScript files loaded after rails-bundle.js
5260
// in the Rails Asset Pipeline. Thus, load this one prior.
5361
{ test: require.resolve("jquery"), loader: "expose?jQuery" },

0 commit comments

Comments
 (0)