-
Notifications
You must be signed in to change notification settings - Fork 39
/
webpack.config.js
97 lines (93 loc) · 2.42 KB
/
webpack.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
86
87
88
89
90
91
92
93
94
95
96
97
/* eslint-disable no-var, strict, prefer-arrow-callback */
"use strict";
var path = require("path");
var webpack = require("webpack");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
var packageJson = require("./package.json");
var vendorDependencies = Object.keys(packageJson["dependencies"]);
module.exports = {
cache: true,
entry: {
main: "./dev/index.tsx",
vendor: vendorDependencies,
},
output: {
path: path.resolve(__dirname, "./dist"),
filename: "[name].js",
chunkFilename: "[chunkhash].js",
},
module: {
rules: [
{
test: /\.ts(x?)$/,
exclude: /node_modules/,
use: [
{
loader: "ts-loader",
options: { transpileOnly: true },
},
],
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.scss$/,
use: [
"style-loader",
"css-loader",
"sass-loader",
{
loader: "@epegzz/sass-vars-loader", // read Sass vars from file or options
options: {
files: [path.resolve(__dirname, "src/styles/colors.js")],
},
},
],
},
{
test: /\.svg/,
use: [{ loader: "svg-sprite-loader", options: { symbolId: "[name]" } }],
},
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: "ts-loader",
options: { transpileOnly: true },
},
],
},
],
},
plugins: [
new ForkTsCheckerWebpackPlugin({
tslint: true,
watch: ["./src", "./test"], // optional but improves performance (less stat calls)
}),
new HtmlWebpackPlugin({
template: "dev/index.html", // Load a custom template (lodash by default see the FAQ for details)
}),
new webpack.optimize.CommonsChunkPlugin({
name: "vendor",
// filename: "vendor.js"
// (Give the chunk a different name)
minChunks: Infinity,
// (with more entries, this ensures that no other module
// goes into the vendor chunk)
}),
],
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: [".ts", ".tsx", ".js"],
},
devServer: {
contentBase: path.join(__dirname, "dist"),
compress: true,
port: 9000,
},
devtool: "source-map",
};