-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
102 lines (100 loc) · 2.61 KB
/
webpack.config.js
File metadata and controls
102 lines (100 loc) · 2.61 KB
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
const path = require('path');
const glob = require('glob');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const entry = glob.sync('./src/pages/*.js', { dotRelative: true }).reduce((acc, curr) => ({ ...acc, [path.basename(curr, '.js')]: curr }), {})
const htmlWebpackPlugins = Object.keys(entry).map((file) => {
return new HtmlWebpackPlugin({
title: 'Sarah Port (っ·ᴥ·)っ',
favicon: './src/images/favico.png',
// inject: false,
chunks: [file],
filename: file === 'index' ? 'index.html' : `${file}/index.html` // TODO: Why can't I use '[name].html'?
})
})
module.exports = {
mode: 'development',
entry,
plugins: [
...htmlWebpackPlugins,
new CopyWebpackPlugin({
patterns: [{ from: './archive', to: '.' }, { from: './src/public', to: './public'}]
})
],
devtool: 'inline-source-map',
devServer: {
static: './dist',
port: 3000,
hot: true,
// historyApiFallback: true,
},
module: {
rules: [
{
test: /\.(png|jpg|jpeg|gif)$/i,
type: 'asset/resource',
},
{
test: /\.svg$/,
use: [{
loader: '@svgr/webpack',
// TODO: why does disabling removeViewBox break the d path animations??
// options: {
// svgoConfig: {
// plugins: [
// {
// name: 'preset-default',
// params: {
// overrides: {
// // disable plugins
// removeViewBox: false,
// },
// },
// },
// ],
// }
// }
}],
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.m?jsx?$/,
exclude: [/node_modules/, /\.test\.m?jsx$/],
use: {
loader: 'babel-loader',
}
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: [/node_modules/, /\.test\/\.tsx?$/],
},
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
"style-loader",
// Translates CSS into CommonJS
"css-loader",
// Compiles Sass to CSS
"sass-loader",
],
},
]
},
resolve: {
extensions: ['', '.js', '.jsx', '.ts', '.tsx', '.scss'],
alias: {
"@": path.resolve(__dirname, "src"),
}
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
// publicPath: "/",
clean: true,
},
};