2022-04-19 12:21:37 +02:00
|
|
|
const path = require("path");
|
|
|
|
const CopyPlugin = require("copy-webpack-plugin");
|
2022-06-09 12:14:30 +02:00
|
|
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
2022-04-19 12:21:37 +02:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
mode: "production",
|
|
|
|
entry: {
|
|
|
|
app: "./src/index.ts",
|
|
|
|
sw: "./src/sw.js"
|
|
|
|
},
|
|
|
|
devServer: {
|
|
|
|
watchFiles: ["src/**/*"],
|
2022-06-09 12:14:30 +02:00
|
|
|
static: {
|
|
|
|
directory: path.resolve(__dirname, "src")
|
|
|
|
},
|
2022-04-19 12:21:37 +02:00
|
|
|
port: 3000
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
use: "ts-loader",
|
|
|
|
exclude: /node_modules/,
|
|
|
|
include: [path.resolve(__dirname, "src")]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
filename: ({runtime}) => {
|
|
|
|
if (runtime === 'sw') {
|
2022-06-09 12:14:30 +02:00
|
|
|
return '[name].js';
|
2022-04-19 12:21:37 +02:00
|
|
|
}
|
2022-06-09 12:14:30 +02:00
|
|
|
return 'bundle.js';
|
2022-04-19 12:21:37 +02:00
|
|
|
},
|
2022-06-09 12:14:30 +02:00
|
|
|
path: path.resolve(__dirname + "/dist")
|
2022-04-19 12:21:37 +02:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: [".tsx", ".ts", ".js"]
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [
|
2022-06-09 12:19:25 +02:00
|
|
|
{ from: "src/index.html", to: "index.html" },
|
|
|
|
{ from: "src/manifest.json", to: "manifest.json" },
|
|
|
|
{ from: "src/CNAME", to: "CNAME" },
|
|
|
|
{ from: "src/assets", to: "assets" }
|
2022-04-19 12:21:37 +02:00
|
|
|
]
|
2022-06-09 12:14:30 +02:00
|
|
|
}),
|
|
|
|
new CleanWebpackPlugin()
|
2022-04-19 12:21:37 +02:00
|
|
|
]
|
|
|
|
}
|