config
This commit is contained in:
parent
b806162f6e
commit
00958ca1b1
12
index.html
12
index.html
@ -1,12 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<link rel="icon" type="image/svg+xml" href="/react.svg" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>Rspack + React + TS</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="root"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,16 +1,18 @@
|
|||||||
|
import * as path from "path";
|
||||||
import { defineConfig } from "@rspack/cli";
|
import { defineConfig } from "@rspack/cli";
|
||||||
import { rspack } from "@rspack/core";
|
import { rspack } from "@rspack/core";
|
||||||
import * as RefreshPlugin from "@rspack/plugin-react-refresh";
|
import * as RefreshPlugin from "@rspack/plugin-react-refresh";
|
||||||
|
import { version } from "./package.json";
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV === "development";
|
const isDev = process.env.NODE_ENV === "development";
|
||||||
|
const isBeta = version.includes("-");
|
||||||
|
|
||||||
// Target browsers, see: https://github.com/browserslist/browserslist
|
// Target browsers, see: https://github.com/browserslist/browserslist
|
||||||
const targets = ["chrome >= 87", "edge >= 88", "firefox >= 78", "safari >= 14"];
|
const targets = ["chrome >= 87", "edge >= 88", "firefox >= 78", "safari >= 14"];
|
||||||
|
|
||||||
const src = `${__dirname}/src`;
|
const src = `${__dirname}/src`;
|
||||||
const dist = `${__dirname}/dist`;
|
const dist = `${__dirname}/dist`;
|
||||||
const assets = `${__dirname}/build/assets`;
|
const assets = `${src}/assets`;
|
||||||
const template = `${assets}/template`;
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
context: __dirname,
|
context: __dirname,
|
||||||
@ -18,8 +20,17 @@ export default defineConfig({
|
|||||||
service_worker: `${src}/service_worker.ts`,
|
service_worker: `${src}/service_worker.ts`,
|
||||||
popup: `${src}/pages/popup/main.tsx`,
|
popup: `${src}/pages/popup/main.tsx`,
|
||||||
},
|
},
|
||||||
|
output: {
|
||||||
|
path: `${dist}/ext/src`,
|
||||||
|
filename: "[name].js",
|
||||||
|
clean: true,
|
||||||
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ["...", ".ts", ".tsx", ".jsx"],
|
extensions: ["...", ".ts", ".tsx", ".jsx"],
|
||||||
|
alias: {
|
||||||
|
"@App": path.resolve(__dirname, "src/"),
|
||||||
|
"@Pkg": path.resolve(__dirname, "pkg/"),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
@ -54,6 +65,29 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
new rspack.CopyRspackPlugin({
|
||||||
|
patterns: [
|
||||||
|
{
|
||||||
|
from: `${src}/manifest.json`,
|
||||||
|
to: `${dist}/ext`,
|
||||||
|
// 将manifest.json内版本号替换为package.json中版本号
|
||||||
|
transform(content) {
|
||||||
|
const manifest = JSON.parse(content.toString());
|
||||||
|
manifest.name = "ScriptCat - Dev";
|
||||||
|
manifest.content_security_policy = "script-src 'self' https://cdn.crowdin.com; object-src 'self'";
|
||||||
|
return JSON.stringify(manifest);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: `${assets}/logo/logo${isDev ? "-beta" : ""}.png`,
|
||||||
|
to: `${dist}/ext/assets/logo.png`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: `${assets}/_locales`,
|
||||||
|
to: `${dist}/ext/src/_locales`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
new rspack.HtmlRspackPlugin({
|
new rspack.HtmlRspackPlugin({
|
||||||
filename: `${dist}/ext/src/popup.html`,
|
filename: `${dist}/ext/src/popup.html`,
|
||||||
template: `${src}/pages/popup/index.html`,
|
template: `${src}/pages/popup/index.html`,
|
||||||
|
11
src/assets/_locales/en/messages.json
Normal file
11
src/assets/_locales/en/messages.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"i18n": {
|
||||||
|
"message": "i18n"
|
||||||
|
},
|
||||||
|
"scriptcat": {
|
||||||
|
"message": "ScriptCat"
|
||||||
|
},
|
||||||
|
"scriptcat_description": {
|
||||||
|
"message": "Everything can be scripted, allowing your browser to do more!"
|
||||||
|
}
|
||||||
|
}
|
11
src/assets/_locales/vi/messages.json
Normal file
11
src/assets/_locales/vi/messages.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"i18n": {
|
||||||
|
"message": "I18n"
|
||||||
|
},
|
||||||
|
"scriptcat": {
|
||||||
|
"message": "ScriptCat"
|
||||||
|
},
|
||||||
|
"scriptcat_description": {
|
||||||
|
"message": "Mọi thứ đều có thể viết được, cho phép trình duyệt của bạn làm được nhiều việc hơn!"
|
||||||
|
}
|
||||||
|
}
|
11
src/assets/_locales/zh_CN/messages.json
Normal file
11
src/assets/_locales/zh_CN/messages.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"i18n": {
|
||||||
|
"message": "i18n"
|
||||||
|
},
|
||||||
|
"scriptcat": {
|
||||||
|
"message": "脚本猫"
|
||||||
|
},
|
||||||
|
"scriptcat_description": {
|
||||||
|
"message": "万物皆可脚本化,让你的浏览器可以做更多的事情!"
|
||||||
|
}
|
||||||
|
}
|
BIN
src/assets/logo/gf.png
Normal file
BIN
src/assets/logo/gf.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
src/assets/logo/github.png
Normal file
BIN
src/assets/logo/github.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 958 B |
BIN
src/assets/logo/logo-beta.png
Normal file
BIN
src/assets/logo/logo-beta.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
BIN
src/assets/logo/logo.png
Normal file
BIN
src/assets/logo/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
@ -1,15 +1,10 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
<title><%= htmlRspackPlugin.options.title %></title>
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div id="root"></div>
|
|
||||||
</body>
|
|
||||||
<style>
|
<style>
|
||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
@ -26,11 +21,13 @@
|
|||||||
/* overflow: hidden; */
|
/* overflow: hidden; */
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<% if (htmlWebpackPlugin.options.mode === 'i18n') { %>
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
</body>
|
||||||
|
<% if rspackConfig.mode=="script" { %>
|
||||||
<script type="text/javascript" src="/_locales/i18n.js"></script>
|
<script type="text/javascript" src="/_locales/i18n.js"></script>
|
||||||
<script
|
<script type="text/javascript" src="https://cdn.crowdin.com/jipt/jipt.js"></script>
|
||||||
type="text/javascript"
|
|
||||||
src="https://cdn.crowdin.com/jipt/jipt.js"
|
|
||||||
></script>
|
|
||||||
<% } %>
|
<% } %>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user