feat(static): use webpack instead of vite
This commit is contained in:
69
static/webpack.config.ts
Normal file
69
static/webpack.config.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import CopyPlugin from "copy-webpack-plugin";
|
||||
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "url";
|
||||
import webpack from "webpack";
|
||||
import packageInfo from "./package.json" with { type: "json" };
|
||||
|
||||
// in case you run into any TypeScript error when configuring `devServer`
|
||||
//import "webpack-dev-server";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const config: webpack.Configuration = {
|
||||
entry: ["./src/index.ts", "./src/main.scss"],
|
||||
module: {
|
||||
rules: [
|
||||
{ test: /\.svg$/, use: ["file-loader"] },
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: {
|
||||
loader: "ts-loader",
|
||||
options: {
|
||||
transpileOnly: true, // TODO: fix errors
|
||||
},
|
||||
},
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
{
|
||||
test: /\.s[ac]ss$/i,
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
{ loader: "css-loader", options: { sourceMap: true, url: false } },
|
||||
{ loader: "sass-loader", options: { sourceMap: true } },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
extensions: [".tsx", ".ts", ".js"],
|
||||
},
|
||||
output: {
|
||||
filename: `${packageInfo.name}.js`,
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
clean: true,
|
||||
},
|
||||
plugins: [
|
||||
new MiniCssExtractPlugin({ filename: `${packageInfo.name}.css` }),
|
||||
new CopyPlugin({
|
||||
patterns: [
|
||||
{
|
||||
from: "./src/**/*.svg",
|
||||
//to: "[path][name].[contenthash][ext]",
|
||||
to: "svg/[name][ext]",
|
||||
},
|
||||
{
|
||||
from: "./node_modules/bootstrap-icons/icons/*.svg",
|
||||
to: "bootstrap-icons/icons/[name][ext]",
|
||||
},
|
||||
{
|
||||
from: "./node_modules/flag-icons/flags/1x1/*.svg",
|
||||
to: "flag-icons/flags/1x1/[name][ext]",
|
||||
}
|
||||
],
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
export default config;
|
||||
Reference in New Issue
Block a user