-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.common.ts
117 lines (114 loc) · 2.75 KB
/
webpack.common.ts
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* eslint-disable no-magic-numbers, no-console */
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import path from 'path';
import webpack from 'webpack';
const config: webpack.Configuration = {
amd: false,
entry: ['./src/components/index.tsx'],
context: __dirname,
output: {
publicPath: '/',
path: path.resolve(__dirname, 'dist'),
filename: 'assets/[name].[chunkhash:12].js',
chunkFilename: 'assets/[id].[chunkhash:12].js',
},
module: {
rules: [
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
{
test: /\.(png|jpg)$/,
loader: 'url-loader',
options: {
limit: 8192,
},
},
{
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader',
options: {
limit: 10000,
mimetype: 'application/font-woff',
name: 'assets/[name].[contenthash:12].[ext]',
},
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader',
options: {
limit: 10000,
mimetype: 'application/octet-stream',
name: 'assets/[name].[contenthash:12].[ext]',
},
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader',
options: {
name: 'assets/[name].[contenthash:12].[ext]',
},
},
{
test: /\.md(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader',
options: {
name: 'assets/[name].[contenthash:12].[ext]',
},
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader',
options: {
limit: 10000,
esModule: false,
mimetype: 'image/svg+xml',
},
},
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'raw-loader',
},
{
test: /node_modules\/vfile\/core\.js/,
use: [
{
loader: 'imports-loader',
options: {
type: 'commonjs',
imports: ['single process/browser process'],
},
},
],
},
],
},
resolve: {
extensions: ['.*', '.js', '.jsx', '.ts', '.tsx'],
modules: [
'node_modules',
path.resolve(`${__dirname}/src`),
path.resolve(`${__dirname}/src/components`),
],
fallback: {
fs: false,
path: false,
querystring: false,
},
symlinks: false,
cacheWithContext: false,
},
plugins: [
new CleanWebpackPlugin() as unknown as webpack.WebpackPluginInstance,
new HtmlWebpackPlugin({
template: 'src/index.ejs',
filename: 'index.ejs',
}),
],
};
export default config;