-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
89 lines (88 loc) · 2.59 KB
/
webpack.common.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
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackRootPlugin = require("html-webpack-root-plugin");
// const CnameWebpackPlugin = require("cname-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const MomentLocalesWebpackPlugin = require("moment-locales-webpack-plugin");
module.exports = {
entry: {
app: "./src/components/App/App.tsx"
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].bundle.js"
},
resolve: {
// TODO add aliases here for /components/, /src/, to remove need for lots of /../
extensions: [".ts", ".tsx", ".js", ".jsx", ".scss"]
},
module: {
rules: [
{
test: /\.(ts|tsx|js|jsx)$/,
loader: "ts-loader",
options: {
// disable type checker - typecheck will happen via eslint
transpileOnly: true
}
},
{
test: /\.scss$/,
exclude: /\.module\.scss$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"]
},
{
test: /\.module\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
modules: {
localIdentName: "[name]__[local]___[hash:base64:5]"
},
// replace kebab-case css class names with camelCase strings
// so they can keep their conventions in both css and js
localsConvention: "dashesOnly"
}
},
"sass-loader"
]
},
{
test: /\.(png|svg|jpg|gif|pdf|docx)$/,
loader: "file-loader",
options: {
name: "[name].[hash:base64:5].[ext]"
}
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
loader: "file-loader"
}
]
},
plugins: [
new CopyPlugin({
patterns: [{ from: "src/img/favicons", to: "img/favicons" }]
}),
new CleanWebpackPlugin(),
new ForkTsCheckerWebpackPlugin({
eslint: false
}),
new HtmlWebpackPlugin({
template: "src/template.html"
}),
new HtmlWebpackRootPlugin(),
// only want a cname when hosting the app on its own domain
// new CnameWebpackPlugin({
// domain: "dargacode.com"
// }),
new MiniCssExtractPlugin(),
new MomentLocalesWebpackPlugin()
]
};