forked from shakacode/react-webpack-rails-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.client.rails.build.config.js
75 lines (64 loc) · 1.9 KB
/
webpack.client.rails.build.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Run like this:
// cd client && npm run build:client
// Note that Foreman (Procfile.dev) has also been configured to take care of this.
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const config = require('./webpack.client.base.config');
const devBuild = process.env.NODE_ENV !== 'production';
config.output = {
filename: '[name]-bundle.js',
path: '../app/assets/webpack',
};
// You can add entry points specific to rails here
config.entry.vendor.unshift(
'es5-shim/es5-shim',
'es5-shim/es5-sham',
'jquery-ujs',
// Configures extractStyles to be true if NODE_ENV is production
'bootstrap-loader/extractStyles'
);
// See webpack.common.config for adding modules common to both the webpack dev server and rails
config.module.loaders.push(
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract(
'style',
'css?minimize&modules&importLoaders=1&localIdentName=[name]__[local]__[hash:base64:5]' +
'!postcss'
),
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract(
'style',
'css?minimize&modules&importLoaders=3&localIdentName=[name]__[local]__[hash:base64:5]' +
'!postcss' +
'!sass' +
'!sass-resources'
),
},
{
test: require.resolve('react'),
loader: 'imports?shim=es5-shim/es5-shim&sham=es5-shim/es5-sham',
},
{
test: require.resolve('jquery-ujs'),
loader: 'imports?jQuery=jquery',
}
);
config.plugins.push(
new ExtractTextPlugin('[name]-bundle.css', { allChunks: true }),
new webpack.optimize.DedupePlugin()
);
if (devBuild) {
console.log('Webpack dev build for Rails'); // eslint-disable-line no-console
config.devtool = 'eval-source-map';
} else {
console.log('Webpack production build for Rails'); // eslint-disable-line no-console
}
module.exports = config;