-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.common.js
More file actions
101 lines (100 loc) · 2.67 KB
/
webpack.common.js
File metadata and controls
101 lines (100 loc) · 2.67 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
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const Dotenv = require('dotenv-webpack');
module.exports = {
entry: './src/index.ts',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'Heylynx-bundle.js',
clean: true,
},
resolve: {
plugins: [new TsconfigPathsPlugin()],
alias: {
src: path.resolve(__dirname, './src'),
store: path.resolve(__dirname, './src/store'),
components: path.resolve(__dirname, './src/components'),
core: path.resolve(__dirname, './src/core'),
helpers: path.resolve(__dirname, './src/helpers'),
pages: path.resolve(__dirname, './src/pages'),
images: path.resolve(__dirname, './src/images'),
icons: path.resolve(__dirname, './src/icons'),
data: path.resolve(__dirname, './src/data'),
utils: path.resolve(__dirname, './src/utils'),
api: path.resolve(__dirname, './src/api'),
services: path.resolve(__dirname, './src/services'),
tests: path.resolve(__dirname, './src/tests'),
handlebars: 'handlebars/dist/handlebars.js',
},
fallback: {
fs: false,
},
extensions: ['.ts', '.js', '.json'],
},
plugins: [
new CopyPlugin({
patterns: [
{
from: '**.*',
context: path.resolve(__dirname, 'src', 'assets'),
to: './assets',
},
],
}),
new HtmlPlugin({
template: './src/index.html',
filename: 'index.html',
inject: 'body',
minify: {
collapseWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
useShortDoctype: true,
},
}),
new MiniCssExtractPlugin({
filename: 'style-[hash].css',
}),
new Dotenv(),
],
module: {
rules: [
{
test: /\.ts$/,
use: [
{
loader: 'ts-loader',
options: {
configFile: path.resolve(__dirname, 'tsconfig.json'),
transpileOnly: true,
},
},
],
exclude: /(node_modules)/,
},
{
test: /\.(sa|sc|c)ss$/i,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
{
test: /\.(?:svg|png|jpg|jpeg|webp|ico)$/i,
use: [
{
loader: 'file-loader?name=assets/img/[name].[ext]',
},
],
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
},
],
},
};