-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.prod.js
More file actions
84 lines (80 loc) · 2.51 KB
/
webpack.config.prod.js
File metadata and controls
84 lines (80 loc) · 2.51 KB
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
84
// See https://github.com/webpack/css-loader/issues/145
require('es6-promise').polyfill();
/* Generate a manifest.json file in the root output directory with a mapping of all
source file names to their corresponding output file. */
var ManifestPlugin = require('webpack-manifest-plugin');
/* Moves every require("....css") into a separate CSS files (not inlined in the JS bundle) */
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var webpack = require("webpack");
module.exports = {
entry: {
common: "./app/assets/javascripts/common.js",
main: "./app/assets/javascripts/main.js"
},
output: {
path: __dirname + "/public/assets",
publicPath: '/assets/',
filename: "javascripts/[name]-[chunkhash].js",
chunkFilename: "javascripts/[name]-[chunkhash].js"
},
// assume extensions when resolving dependenies
resolve: {
extensions: [".js", ".jsx"]
},
target: 'web',
plugins: [
new ManifestPlugin({
publicPath: '/assets/'
}),
new ExtractTextPlugin("stylesheets/[name]-[contenthash].css"),
new webpack.optimize.UglifyJsPlugin({ output: { comments: false } })
],
module: {
rules: [
// transpile es6 to es5 with babel.
{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
},
// extract css into a separate file from js file.
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
},
// convert scss to css and extract to a css file.
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{ loader: "css-loader" },
{ loader: "sass-loader" }
]
})
},
{
test: /\.(jpe?g|png|gif|svg)(\?[a-z0-9.=]+)?$/i,
loader: 'file-loader',
options: {
name: 'images/[name]-[hash].[ext]',
hash: 'sha512&digest=hex'
}
},
{
test: /\.(eot|svg|ttf|woff|woff2)(\?[a-z0-9.=]+)?$/,
loader: 'file-loader',
options: {
name: 'fonts/[name]-[hash].[ext]',
hash: 'sha512&digest=hex'
}
}
]
}
};