Files
gallery/static/webpack.config.ts

66 lines
1.7 KiB
TypeScript

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" };
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/lib/weather-icons/icons/*.svg",
to: "weather-icons/icons/[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;