First commit
This commit is contained in:
74
web/webpack.config.js
Normal file
74
web/webpack.config.js
Normal file
@@ -0,0 +1,74 @@
|
||||
const path = require("path");
|
||||
const webpack = require("webpack");
|
||||
const CopyPlugin = require("copy-webpack-plugin");
|
||||
|
||||
module.exports = {
|
||||
mode: process.env.NODE_ENV === "development" ? "development" : "production",
|
||||
devtool: process.env.NODE_ENV === "development" ? "source-map" : false,
|
||||
entry: {
|
||||
index: path.resolve(__dirname, "src/index.tsx")
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
filename: "[name].bundle.js",
|
||||
clean: true
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: [{
|
||||
loader: "ts-loader",
|
||||
options: {
|
||||
configFile: path.resolve(__dirname, "src/tsconfig.json")
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
test: /\.s?[ac]ss$/,
|
||||
use: ["style-loader", "css-loader", "sass-loader"]
|
||||
},
|
||||
{
|
||||
test: /\.(png|woff|woff2|eot|ttf)$/,
|
||||
type: "asset/resource",
|
||||
generator: {
|
||||
filename: "assets/[hash][ext]"
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.svg$/,
|
||||
type: "asset/inline"
|
||||
}
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
extensions: [".ts", ".tsx", ".js", ".json"]
|
||||
},
|
||||
plugins: [
|
||||
new CopyPlugin({
|
||||
patterns: [{
|
||||
from: "**/*.{html,svg}",
|
||||
to: "[path][name][ext]",
|
||||
context: path.resolve(__dirname, "src")
|
||||
}]
|
||||
}),
|
||||
new webpack.ProvidePlugin({
|
||||
Buffer: ["buffer", "Buffer"]
|
||||
}),
|
||||
new webpack.ProvidePlugin({
|
||||
process: "process/browser.js"
|
||||
})
|
||||
],
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
vendors: {
|
||||
test: /node_modules/,
|
||||
name: "vendors",
|
||||
chunks: "all",
|
||||
enforce: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user