-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.base.config.js
87 lines (83 loc) · 2.34 KB
/
webpack.base.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
84
85
let webpack = require("webpack");
let path = require("path");
let HtmlWebpackPlugin = require("html-webpack-plugin");
let CopyWebpackPlugin = require('copy-webpack-plugin');
let basePath = __dirname;
module.exports = {
context: path.join(basePath, "src"),
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx", ".css", ".scss", "json"]
},
entry: {
bundle: ["./app/app.tsx"]
// TODO: Ask why separating vendor into a different bundle creates a heavier result?
// vendor: ["d3", "react", "react-dom", "react-css-themr", "react-addons-css-transition-group",
// "react-sortable-hoc", "react-toolbox", "postcss"]
},
module: {
// *** Typescript ***
rules: [{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
use: {
loader: "awesome-typescript-loader",
options: {
useBabel: true
}
}
},
// *** Images ***
{
test: /\.(png|jpg|gif|bmp)$/,
exclude: [/node_modules/],
use: [{
loader: "file-loader",
options: {
name: "public/images/[name].[ext]"
}
}]
},
// *** Vector ***
{
test: /\.svg$/,
exclude: [/node_modules/],
use: [{
loader: "file-loader",
options: {
name: "public/vector/[name].[ext]"
}
}]
},
// *** Fonts ***
{
test: /\.woff$/,
loader: "url-loader?limit=65000&mimetype=application/font-woff&name=public/fonts/[name].[ext]"
},
{
test: /\.woff2$/,
loader: "url-loader?limit=65000&mimetype=application/font-woff2&name=public/fonts/[name].[ext]"
},
{
test: /\.[ot]tf$/,
loader: "url-loader?limit=65000&mimetype=application/octet-stream&name=public/fonts/[name].[ext]"
},
{
test: /\.eot$/,
loader: "url-loader?limit=65000&mimetype=application/vnd.ms-fontobject&name=public/fonts/[name].[ext]"
}]
},
plugins: [
// Generate index.html in /dist => https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: "index.html", //Name of file in ./dist/
template: "index.html", //Name of template in ./src
hash: true
}),
new webpack.optimize.CommonsChunkPlugin({
names: ["vendor", "manifest"]
}),
new CopyWebpackPlugin([
{context: "app/favicon", from: "**/*", to: "public/favicon"}
])
]
};