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 { rspack } from "@rspack/core";
|
||||
import * as RefreshPlugin from "@rspack/plugin-react-refresh";
|
||||
import { version } from "./package.json";
|
||||
|
||||
const isDev = process.env.NODE_ENV === "development";
|
||||
const isBeta = version.includes("-");
|
||||
|
||||
// Target browsers, see: https://github.com/browserslist/browserslist
|
||||
const targets = ["chrome >= 87", "edge >= 88", "firefox >= 78", "safari >= 14"];
|
||||
|
||||
const src = `${__dirname}/src`;
|
||||
const dist = `${__dirname}/dist`;
|
||||
const assets = `${__dirname}/build/assets`;
|
||||
const template = `${assets}/template`;
|
||||
const assets = `${src}/assets`;
|
||||
|
||||
export default defineConfig({
|
||||
context: __dirname,
|
||||
@ -18,8 +20,17 @@ export default defineConfig({
|
||||
service_worker: `${src}/service_worker.ts`,
|
||||
popup: `${src}/pages/popup/main.tsx`,
|
||||
},
|
||||
output: {
|
||||
path: `${dist}/ext/src`,
|
||||
filename: "[name].js",
|
||||
clean: true,
|
||||
},
|
||||
resolve: {
|
||||
extensions: ["...", ".ts", ".tsx", ".jsx"],
|
||||
alias: {
|
||||
"@App": path.resolve(__dirname, "src/"),
|
||||
"@Pkg": path.resolve(__dirname, "pkg/"),
|
||||
},
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
@ -54,6 +65,29 @@ export default defineConfig({
|
||||
],
|
||||
},
|
||||
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({
|
||||
filename: `${dist}/ext/src/popup.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,36 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
<title><%= htmlRspackPlugin.options.title %></title>
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
background-color: var(--color-bg-2);
|
||||
color: var(--color-text-1);
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
width: 320px;
|
||||
/* height: 500px; */
|
||||
min-height: 150px;
|
||||
max-height: 500px;
|
||||
/* overflow-y: auto; */
|
||||
/* overflow: hidden; */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
background-color: var(--color-bg-2);
|
||||
color: var(--color-text-1);
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
width: 320px;
|
||||
/* height: 500px; */
|
||||
min-height: 150px;
|
||||
max-height: 500px;
|
||||
/* overflow-y: auto; */
|
||||
/* overflow: hidden; */
|
||||
}
|
||||
</style>
|
||||
<% if (htmlWebpackPlugin.options.mode === 'i18n') { %>
|
||||
<% if rspackConfig.mode=="script" { %>
|
||||
<script type="text/javascript" src="/_locales/i18n.js"></script>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="https://cdn.crowdin.com/jipt/jipt.js"
|
||||
></script>
|
||||
<script type="text/javascript" src="https://cdn.crowdin.com/jipt/jipt.js"></script>
|
||||
<% } %>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user