-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.js
95 lines (94 loc) · 2.35 KB
/
webpack.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
const path = require('path');
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = () => {
return {
mode: 'development',
target: 'web',
name: 'sonic-app',
entry: './src/index.tsx',
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
uniqueName: 'sonic-app',
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
alias: {
'@': path.join(__dirname, '/src'),
},
},
performance: {
maxAssetSize: 650 * 1024,
maxEntrypointSize: 650 * 1024,
},
output: {
filename: 'static/js/[name].js',
chunkFilename: 'static/js/[name].js',
},
devtool: 'cheap-module-source-map',
devServer: {
hot: true,
compress: true,
historyApiFallback: { disableDotRule: true },
port: 9000,
static: {
directory: path.join(__dirname, 'dist'),
},
devMiddleware: {
index: true,
mimeTypes: { 'text/html': ['phtml'] },
serverSideRender: true,
writeToDisk: true,
},
},
module: {
rules: [
{
test: /\.ts(x?)$/,
loader: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
},
{
test: /\.(png|jpg|jpeg|gif)$/i,
type: 'asset/resource',
},
{
test: /\.svg/,
type: 'asset/inline',
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
],
},
plugins: [
new CleanWebpackPlugin(),
new webpack.ProvidePlugin({
Buffer: [require.resolve('buffer/'), 'Buffer'],
process: 'process/browser',
}),
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, 'public'),
globOptions: {
ignore: ['**/index.html'],
},
},
],
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'public/index.html'),
inject: true,
}),
],
};
};