forked from shakacode/bootstrap-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.config.js
83 lines (73 loc) · 2.26 KB
/
webpack.prod.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
76
77
78
79
80
81
82
83
// Very similar to webpack.dev.config.js. Common parts could be extracted to a base config.
// See example at:
// https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client%2Fwebpack.client.base.config.js
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
const autoprefixer = require('autoprefixer');
const bootstrapEntryPoints = require('./webpack.bootstrap.config.js');
// eslint-disable-next-line no-console
console.log(`=> bootstrap-loader configuration: ${bootstrapEntryPoints.prod}`);
module.exports = {
// For production build we want to extract CSS to stand-alone file
// Provide `extractStyles` param and `bootstrap-loader` will handle it
entry: [
'font-awesome-loader',
bootstrapEntryPoints.prod,
'tether',
'./app/startup/App',
],
output: {
path: path.join(__dirname, 'public', 'assets'),
filename: 'app.js',
},
resolve: { extensions: ['', '.js', '.jsx'] },
plugins: [
new ExtractTextPlugin({ filename: 'app.css', allChunks: true }),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
new webpack.ProvidePlugin({
'window.Tether': 'tether',
}),
],
module: {
loaders: [
{
test: /\.jsx?$/,
loaders: ['babel'],
exclude: /node_modules/,
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style',
loader: 'css?modules&importLoaders=1&localIdentName=[name]__[local]__[hash:base64:5]' +
'!postcss',
}),
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style',
loader: 'css?modules&importLoaders=2&localIdentName=[name]__[local]__[hash:base64:5]' +
'!postcss' +
'!sass',
}),
},
{
test: /\.woff2?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
// Limiting the size of the woff fonts breaks font-awesome ONLY for the extract text plugin
// loader: "url?limit=10000"
loader: 'url',
},
{
test: /\.(ttf|eot|svg)(\?[\s\S]+)?$/,
loader: 'file',
},
],
},
postcss: [autoprefixer],
};