-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
79 lines (77 loc) · 2.03 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
const path = require('path')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const Sass = require('sass')
module.exports = (env, argv) => {
const isProd = argv.mode === 'production'
const distPath = path.resolve(__dirname, isProd ? 'docs' : 'dist')
return {
mode: 'development',
entry: {
app: './src/index.ts',
},
devServer: {
static: {
directory: path.join(__dirname, 'public'),
},
compress: isProd,
port: 3000,
},
devtool: argv.mode === 'production' ? undefined : 'inline-source-map',
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'public/index.html'),
filename: 'index.html',
}),
],
output: {
path: distPath,
filename: 'index.js',
publicPath: isProd ? './' : '',
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.s[a|c]ss$/,
use: [
{
loader: 'lit-css-loader',
options: {
transform: (data, { filePath }) =>
Sass.renderSync({ data, file: filePath }).css.toString(),
},
},
],
},
{
test: /\.(png|gif|jpg|cur)$/i,
loader: 'url-loader',
options: { limit: 8192 },
},
{
test: /\.woff2(\?v=[0-9]\.[0-9]\.[0-9])?$/i,
loader: 'url-loader',
options: { limit: 10000, mimetype: 'application/font-woff2' },
},
{
test: /\.woff(\?v=[0-9]\.[0-9]\.[0-9])?$/i,
loader: 'url-loader',
options: { limit: 10000, mimetype: 'application/font-woff' },
},
{
test: /\.(ttf|eot|svg|otf)(\?v=[0-9]\.[0-9]\.[0-9])?$/i,
loader: 'file-loader',
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
}
}