Skip to content

Commit

Permalink
🐛 修复新的注入方式导致dev模式无法正常运行的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Sep 17, 2023
1 parent 4cf6450 commit a96ab94
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package.json
@@ -1,13 +1,13 @@
{
"name": "scriptcat",
"version": "0.15.1",
"version": "0.15.2",
"description": "脚本猫,一个可以执行用户脚本的浏览器扩展,万物皆可脚本化,让你的浏览器可以做更多的事情!",
"author": "CodFrm",
"license": "GPLv3",
"scripts": {
"test": "jest --coverage",
"lint": "eslint --ext .js,.ts,.tsx src/",
"dev": "concurrently \"webpack --mode development --config ./webpack/webpack.dev.ts\" \"webpack --mode development --config ./webpack/webpack.inject.ts\"",
"dev": "concurrently \"webpack --mode development --config ./webpack/webpack.dev.ts\" \"webpack --mode development --config ./webpack/webpack.inject.dev.ts\"",
"build": "webpack --mode production --config ./webpack/webpack.prod.ts && concurrently \"npm run build:linter\" \"npm run build:inject && npm run build:no-split\"",
"build:linter": "webpack --mode production --config ./webpack/webpack.linter.ts",
"build:inject": "webpack --mode production --config ./webpack/webpack.inject.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "ScriptCat",
"version": "0.15.1",
"version": "0.15.2",
"author": "CodFrm",
"description": "脚本猫,一个用户脚本管理器,支持后台脚本、定时脚本、页面脚本,可编写脚本每天帮你自动处理事务.",
"options_ui": {
Expand Down
38 changes: 38 additions & 0 deletions webpack/webpack.inject.dev.ts
@@ -0,0 +1,38 @@
/* eslint-disable import/no-extraneous-dependencies */
import merge from "webpack-merge";
import HtmlWebpackPlugin from "html-webpack-plugin";
import CopyPlugin from "copy-webpack-plugin";
import { CleanWebpackPlugin } from "clean-webpack-plugin";
import common from "../webpack.config";

const src = `${__dirname}/../src`;
const dist = `${__dirname}/../dist`;

// 不要分割的文件
common.entry = {
inject: `${src}/inject.ts`,
};

common.output = {
path: `${dist}`,
filename: "[name].js",
clean: false,
};

// 取消splitChunks
common.optimization = {};

// 移除插件
common.plugins = common.plugins!.filter(
(plugin) =>
!(
plugin instanceof HtmlWebpackPlugin ||
plugin instanceof CopyPlugin ||
plugin instanceof CleanWebpackPlugin
)
);

export default merge(common, {
watch: true,
devtool: "inline-source-map",
});
11 changes: 1 addition & 10 deletions webpack/webpack.inject.ts
Expand Up @@ -2,7 +2,6 @@
import merge from "webpack-merge";
import HtmlWebpackPlugin from "html-webpack-plugin";
import CopyPlugin from "copy-webpack-plugin";
import CompressionPlugin from "compression-webpack-plugin";
import { CleanWebpackPlugin } from "clean-webpack-plugin";
import common from "../webpack.config";

Expand Down Expand Up @@ -33,12 +32,4 @@ common.plugins = common.plugins!.filter(
)
);

export default merge(common, {
plugins: [
// firefox商店文件不能大于4M, 所以需要压缩
new CompressionPlugin({
test: /ts.worker.js/,
deleteOriginalAssets: true,
}),
],
});
export default merge(common, {});

0 comments on commit a96ab94

Please sign in to comment.