flashlang/webpack.config.js

95 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-07-19 22:40:30 +02:00
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const ZipPlugin = require("zip-webpack-plugin");
2020-07-23 16:48:51 +02:00
let mode = process.env.NODE_ENV || "development";
let options = {
2020-07-19 22:40:30 +02:00
entry: {
2020-08-07 13:45:32 +02:00
popup: path.join(__dirname, "src", "frontend", "popup", "popup.ts"),
2020-08-18 22:17:04 +02:00
options: path.join(__dirname, "src", "frontend", "options", "options.ts"),
background: path.join(__dirname, "src", "background", "background.ts"),
2020-07-19 22:40:30 +02:00
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].bundle.js",
},
2020-07-30 11:55:00 +02:00
resolve: {
2020-08-10 00:37:38 +02:00
alias: {
svelte: path.resolve("node_modules", "svelte"),
},
extensions: [".ts", ".mjs", ".js", ".json", ".svelte"],
2020-07-30 11:55:00 +02:00
},
2020-07-23 16:48:51 +02:00
mode: mode,
2020-07-19 22:40:30 +02:00
devtool: "inline-source-map",
module: {
rules: [
{
test: /\.tsx?$/,
oneOf: [
{
2020-08-10 14:54:26 +02:00
resourceQuery: /file/,
use: [
{
loader: "worklet-loader",
options: {
2020-08-12 00:26:31 +02:00
name: "[name]_cs.js",
},
},
"ts-loader",
],
},
{
use: "ts-loader",
},
],
2020-07-19 22:40:30 +02:00
exclude: /node_modules/,
},
2020-07-23 16:48:51 +02:00
{
2020-07-31 00:29:40 +02:00
test: /\.(c|s[ac])ss$/i,
2020-08-10 14:54:26 +02:00
use: ["style-loader", "css-loader", "sass-loader"],
},
2020-08-10 00:37:38 +02:00
{
test: /\.(html|svelte)$/,
use: {
loader: "svelte-loader",
options: {
preprocess: require("svelte-preprocess")({}),
},
},
},
2020-07-19 22:40:30 +02:00
],
},
plugins: [
new CopyPlugin({
2020-08-10 00:37:38 +02:00
patterns: [
{
from: path.resolve(__dirname, "src", "manifest.json"),
},
],
2020-07-19 22:40:30 +02:00
}),
new HtmlWebpackPlugin({
filename: "popup.html",
chunks: ["popup"],
}),
2020-08-18 22:17:04 +02:00
new HtmlWebpackPlugin({
filename: "options.html",
chunks: ["options"],
}),
2020-07-23 16:48:51 +02:00
],
};
if (mode !== "development") {
options.plugins.push(
2020-07-19 22:40:30 +02:00
new ZipPlugin({
filename: "addon",
extension: "xpi",
2020-07-23 16:48:51 +02:00
})
);
}
module.exports = options;