From 1a301791bb621fa01fa76e9403b23fe1f4a120af Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Sun, 5 Feb 2023 22:57:54 +0530 Subject: Added a more extensive way to automate script development. --- webpack.config.js | 52 ---------------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 webpack.config.js (limited to 'webpack.config.js') diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index d98d83f..0000000 --- a/webpack.config.js +++ /dev/null @@ -1,52 +0,0 @@ -const fs = require("fs"); -const path = require("path"); -const CopyPlugin = require("copy-webpack-plugin"); -const manifest = require("./static/manifest.json"); - -const SOURCE_DIR = path.resolve(__dirname, "src"); -const STATIC_DIR = path.resolve(__dirname, "static"); - -const generateScriptBuildConfig = script => { - const scriptName = script.substring(0, script.length - 3); - let entry = path.resolve(SOURCE_DIR, `scripts/${scriptName}.ts`); - if (!fs.existsSync(entry)) { - entry = path.resolve(SOURCE_DIR, `scripts/${scriptName}/index.ts`); - } - - return { - entry, - mode: "production", - output: { - filename: `${scriptName}.js` - }, - resolve: { - extensions: ["", ".ts", ".js", ".sjs"], - alias: { - "@": SOURCE_DIR - } - }, - module: { - rules: [ - { test: /\.sjs$/, loader: "raw-loader" }, - { test: /\.tsx?$/, loader: "ts-loader" } - ] - } - }; -}; - -let scripts = []; - -for (const script of manifest.content_scripts) { - scripts = scripts.concat(script.js.map(generateScriptBuildConfig)); -} - -scripts[scripts.length - 1].plugins = (scripts[scripts.length - 1].plugins || []).concat([ - new CopyPlugin({ - patterns: [{ - from: STATIC_DIR, - to: "./" - }] - }) -]); - -module.exports = scripts; -- cgit v1.2.3