-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.cjs
120 lines (119 loc) · 3.35 KB
/
webpack.config.cjs
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
118
119
120
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
mode: 'development',
entry: './src/ts/chargyApp.ts',
target: 'web',
//devtool: "eval-source-map", // Do not use in production!
devtool: "source-map",
resolve: {
extensions: [".ts", ".js"],
fallback: {
"fs": false,
"original-fs": false,
"path": require.resolve("path-browserify"),
"http": require.resolve("stream-http"),
"crypto": require.resolve("crypto-browserify"),
"url": require.resolve("url/"),
"stream": require.resolve("stream-browserify"),
"vm": require.resolve("vm-browserify"),
"buffer": require.resolve("buffer/"),
"node:buffer": require.resolve("buffer/")
}
},
module: {
rules: [
{
test: /\.ts$/,
include: path.resolve(__dirname, 'src/ts'),
use: [{ loader: 'ts-loader' }]
},
{
// Only .scss files are included, that are included in a .ts file
// e.g. "import './chargy.scss'" within chargyApp.ts
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(woff|woff2|eot|ttf|otf|svg)$/,
type: 'asset/resource',
generator: {
filename: 'assets/fonts/[name][ext][query]' // Path and naming of your fonts
}
},
{
test: /\.(png|jpe?g|gif)$/i,
type: 'asset/resource',
generator: {
// Keep original filename and extension
filename: 'images/[name][ext]'
}
}
]
},
externals: {
'asn1': 'asn1.js',
'base32decode': 'base32-decode'
},
output: {
path: path.resolve(__dirname, 'build'),
filename: 'chargyWebApp-bundle.js'
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new HtmlWebpackPlugin({
template: 'src/index.html'
}),
new MiniCssExtractPlugin({
filename: 'css/chargy.css',
chunkFilename: '[id].css'
}),
new CopyWebpackPlugin({
patterns: [
{
from: '*.css',
to: path.resolve(__dirname, 'build/css'),
context: 'static/css'
},
{
from: path.resolve(__dirname, 'static/css/images'),
to: path.resolve(__dirname, 'build/css/images')
},
{
from: path.resolve(__dirname, 'static/images'),
to: path.resolve(__dirname, 'build/images')
},
{
from: path.resolve(__dirname, 'src/i18n.json'),
to: path.resolve(__dirname, 'build/i18n.json')
},
{
from: path.resolve(__dirname, 'package.json'),
to: path.resolve(__dirname, 'build/package.json')
}
]
})
],
devServer: {
static: {
directory: path.join(__dirname, 'static'),
},
port: 1608,
hot: true,
allowedHosts: ['.chargeit-mobility.com'],
open: true
}
};