flashlang/webpack.config.js
2020-08-20 15:40:04 +02:00

94 lines
1.8 KiB
JavaScript

const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const ZipPlugin = require("zip-webpack-plugin");
let mode = process.env.NODE_ENV || "development";
let options = {
entry: {
popup: path.join(__dirname, "src", "frontend", "popup", "popup.ts"),
options: path.join(__dirname, "src", "frontend", "options", "options.ts"),
background: path.join(__dirname, "src", "background", "background.ts"),
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].bundle.js",
},
resolve: {
alias: {
svelte: path.resolve("node_modules", "svelte"),
},
extensions: [".ts", ".mjs", ".js", ".json", ".svelte"],
},
mode: mode,
devtool: "inline-source-map",
module: {
rules: [
{
test: /\.tsx?$/,
oneOf: [
{
resourceQuery: /file/,
use: [
{
loader: "worklet-loader",
options: {
name: "[name]_cs.js",
},
},
"ts-loader",
],
},
{
use: "ts-loader",
},
],
exclude: /node_modules/,
},
{
test: /\.(c|s[ac])ss$/i,
use: ["style-loader", "css-loader", "sass-loader"],
},
{
test: /\.(html|svelte)$/,
use: {
loader: "svelte-loader",
options: {
preprocess: require("svelte-preprocess")({}),
},
},
},
],
},
plugins: [
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, "src", "manifest.json"),
},
],
}),
new HtmlWebpackPlugin({
filename: "popup.html",
chunks: ["popup"],
}),
new HtmlWebpackPlugin({
filename: "options.html",
chunks: ["options"],
}),
],
};
if (mode !== "development") {
options.plugins.push(
new ZipPlugin({
filename: "addon",
extension: "xpi",
})
);
}
module.exports = options;