-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
114 lines (112 loc) · 3.21 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
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
const webpack = require("webpack");
const path = require("path");
const autoprefixer = require("autoprefixer");
//const initialConfigPlugin = require("./src/init-config").initialConfigPlugin;
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const transform = require("@formatjs/ts-transformer").transform;
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
mode: "development",
devServer: {
contentBase: path.join(__dirname, "public"),
compress: true,
port: 9000,
},
entry: {
// To activate the web server, uncomment below 2 lines and
// add a script to package.json pointing to "webpack-dev-server"
// WebpackDevServer host and port:
// server: 'webpack-dev-server/client?http://localhost:8080',
index: "./src/entry-points/index",
},
output: {
path: path.join(__dirname, "build"),
publicPath: "https://html.eduid.docker/static/front-build/",
filename: "[name]-bundle.dev.js",
},
devtool: "source-map",
resolve: {
// allow us to import components in tests like:
// import Example from 'components/Example';
modules: [path.resolve(__dirname, "src"), "node_modules"],
// allow us to avoid including extension name
extensions: [".js", ".jsx", ".json", ".ts", ".tsx"],
mainFields: ["browser", "module", "main"],
},
optimization: {
emitOnErrors: false,
},
module: {
rules: [
{
test: /\.js$/,
loader: "babel-loader",
exclude: /node_modules/,
},
{
test: /\.tsx?$/,
use: [
{
loader: "ts-loader",
options: {
getCustomTransformers() {
return { before: [transform({ overrideIdFn: "[sha512:contenthash:base64:6]" })] };
},
},
},
],
exclude: /node_modules/,
},
{
test: /\.scss$/,
use: ["style-loader", "css-loader", "postcss-loader", "sass-loader"],
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.(gif|jpg|png)$/,
type: "asset/resource",
},
{
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
type: "asset/resource",
//loader: "url-loader?limit=10000&mimetype=application/font-woff",
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
type: "asset/resource",
//loader: "url-loader?limit=10000&mimetype=application/octet-stream",
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
type: "asset/resource",
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
type: "asset/resource",
//loader: "url-loader?limit=10000&mimetype=image/svg+xml",
},
],
},
plugins: [
// Initial configuration
//initialConfigPlugin,
new HtmlWebpackPlugin({
hash: true,
template: `./public/index.html`,
filename: `index.dev.html`,
chunks: `index`,
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.LoaderOptionsPlugin({
// test: /\.xxx$/, // may apply this only for some modules
options: {
postcss: function () {
return [autoprefixer];
},
},
}),
],
};