mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
41e8fe8c03
commit
ffd94d6b51
9 changed files with 1124 additions and 825 deletions
|
|
@ -10,7 +10,7 @@ export const fillContent = (protyle:IProtyle, data:string, elements:Element[]) =
|
||||||
setLastNodeRange(getContenteditableElement(elements[elements.length - 1]), protyle.toolbar.range);
|
setLastNodeRange(getContenteditableElement(elements[elements.length - 1]), protyle.toolbar.range);
|
||||||
protyle.toolbar.range.collapse(true);
|
protyle.toolbar.range.collapse(true);
|
||||||
insertHTML(data, protyle, true, true);
|
insertHTML(data, protyle, true, true);
|
||||||
}
|
};
|
||||||
|
|
||||||
export const AIActions = (elements: Element[], protyle: IProtyle) => {
|
export const AIActions = (elements: Element[], protyle: IProtyle) => {
|
||||||
const ids: string[] = [];
|
const ids: string[] = [];
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,10 @@
|
||||||
<div id="loading" class="b3-dialog b3-dialog--open">
|
<div id="loading" class="b3-dialog b3-dialog--open">
|
||||||
<div class="b3-dialog__scrim" style="background-color: #212224"></div>
|
<div class="b3-dialog__scrim" style="background-color: #212224"></div>
|
||||||
<img style="position: absolute;width: 36vh;" src="../../icon.png">
|
<img style="position: absolute;width: 36vh;" src="../../icon.png">
|
||||||
<button onclick="window.location.reload()" id="loadingRefresh" style="display: none;position: absolute;bottom: 16px;background: transparent;border: 1px solid #4285f4;color: #4285f4;border-radius: 4px;line-height: 20px;padding: 4px 8px;">Click to Refresh<br>点 击 刷 新</button>
|
<button onclick="window.location.reload()" id="loadingRefresh"
|
||||||
|
style="display: none;position: absolute;bottom: 16px;background: transparent;border: 1px solid #4285f4;color: #4285f4;border-radius: 4px;line-height: 20px;padding: 4px 8px;">
|
||||||
|
Click to Refresh<br>点 击 刷 新
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="toolbar" class="toolbar fn__flex"></div>
|
<div id="toolbar" class="toolbar fn__flex"></div>
|
||||||
<div class="fn__flex-1 fn__flex">
|
<div class="fn__flex-1 fn__flex">
|
||||||
|
|
@ -24,12 +27,12 @@
|
||||||
<div id="commonMenu" class="b3-menu fn__none"></div>
|
<div id="commonMenu" class="b3-menu fn__none"></div>
|
||||||
<div id="message" class="b3-snackbars"></div>
|
<div id="message" class="b3-snackbars"></div>
|
||||||
<script>
|
<script>
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const refreshElement = document.getElementById("loadingRefresh")
|
const refreshElement = document.getElementById("loadingRefresh")
|
||||||
if (refreshElement) {
|
if (refreshElement) {
|
||||||
refreshElement.style.display = ""
|
refreshElement.style.display = ""
|
||||||
}
|
}
|
||||||
}, 2000)
|
}, 2000)
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import {needSubscribe} from "../util/needSubscribe";
|
||||||
|
|
||||||
export const lockScreen = () => {
|
export const lockScreen = () => {
|
||||||
if (window.siyuan.config.readonly) {
|
if (window.siyuan.config.readonly) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
/// #if BROWSER
|
/// #if BROWSER
|
||||||
fetchPost("/api/system/logoutAuth", {}, () => {
|
fetchPost("/api/system/logoutAuth", {}, () => {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ export const mermaidRender = (element: Element, cdn = Constants.PROTYLE_CDN) =>
|
||||||
if (mermaidElements.length === 0) {
|
if (mermaidElements.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addScript(`${cdn}/js/mermaid/mermaid.min.js?v=9.3.0`, "protyleMermaidScript").then(() => {
|
addScript(`${cdn}/js/mermaid/mermaid.min.js?v=9.4.3`, "protyleMermaidScript").then(() => {
|
||||||
const config: any = {
|
const config: any = {
|
||||||
securityLevel: "loose", // 升级后无 https://github.com/siyuan-note/siyuan/issues/3587,可使用该选项
|
securityLevel: "loose", // 升级后无 https://github.com/siyuan-note/siyuan/issues/3587,可使用该选项
|
||||||
altFontFamily: "sans-serif",
|
altFontFamily: "sans-serif",
|
||||||
|
|
|
||||||
1118
app/stage/protyle/js/mermaid/mermaid.min.js
vendored
1118
app/stage/protyle/js/mermaid/mermaid.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -4,120 +4,120 @@ const pkg = require("./package.json");
|
||||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||||
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
|
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
|
||||||
const { EsbuildPlugin } = require("esbuild-loader");
|
const {EsbuildPlugin} = require("esbuild-loader");
|
||||||
|
|
||||||
module.exports = (env, argv) => {
|
module.exports = (env, argv) => {
|
||||||
return {
|
return {
|
||||||
mode: argv.mode || "development",
|
mode: argv.mode || "development",
|
||||||
watch: argv.mode !== "production",
|
watch: argv.mode !== "production",
|
||||||
devtool: argv.mode !== "production" ? "eval" : false,
|
devtool: argv.mode !== "production" ? "eval" : false,
|
||||||
target: "electron-renderer",
|
target: "electron-renderer",
|
||||||
output: {
|
output: {
|
||||||
publicPath: "",
|
publicPath: "auto",
|
||||||
filename: "[name].[chunkhash].js",
|
filename: "[name].[chunkhash].js",
|
||||||
path: path.resolve(__dirname, "stage/build/app"),
|
path: path.resolve(__dirname, "stage/build/app"),
|
||||||
},
|
|
||||||
entry: {
|
|
||||||
"main": "./src/index.ts",
|
|
||||||
"window": "./src/window/index.ts",
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
extensions: [".ts", ".js", ".tpl", ".scss", ".png", ".svg"],
|
|
||||||
},
|
|
||||||
optimization: {
|
|
||||||
minimize: true,
|
|
||||||
minimizer: [
|
|
||||||
new EsbuildPlugin(),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.tpl/,
|
|
||||||
include: [
|
|
||||||
path.resolve(__dirname, "src/assets/template/app/index.tpl"),
|
|
||||||
path.resolve(__dirname, "src/assets/template/app/window.tpl")],
|
|
||||||
loader: "html-loader",
|
|
||||||
options: {
|
|
||||||
sources: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
entry: {
|
||||||
test: /\.ts(x?)$/,
|
"main": "./src/index.ts",
|
||||||
include: [path.resolve(__dirname, "src")],
|
"window": "./src/window/index.ts",
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: "esbuild-loader",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: "ifdef-loader", options: {
|
|
||||||
BROWSER: false,
|
|
||||||
MOBILE: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
resolve: {
|
||||||
test: /\.scss$/,
|
extensions: [".ts", ".js", ".tpl", ".scss", ".png", ".svg"],
|
||||||
include: [
|
|
||||||
path.resolve(__dirname, "src/assets/scss"),
|
|
||||||
],
|
|
||||||
use: [
|
|
||||||
MiniCssExtractPlugin.loader,
|
|
||||||
{
|
|
||||||
loader: "css-loader", // translates CSS into CommonJS
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: "sass-loader", // compiles Sass to CSS
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
optimization: {
|
||||||
test: /\.woff$/,
|
minimize: true,
|
||||||
type: "asset/resource",
|
minimizer: [
|
||||||
generator: {
|
new EsbuildPlugin(),
|
||||||
filename: "../fonts/JetBrainsMono-Regular.woff",
|
],
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
module: {
|
||||||
test: /\.(png|svg)$/,
|
rules: [
|
||||||
use: [
|
{
|
||||||
{
|
test: /\.tpl/,
|
||||||
loader: "file-loader",
|
include: [
|
||||||
options: {
|
path.resolve(__dirname, "src/assets/template/app/index.tpl"),
|
||||||
name: "[name].[ext]",
|
path.resolve(__dirname, "src/assets/template/app/window.tpl")],
|
||||||
outputPath: "../../",
|
loader: "html-loader",
|
||||||
},
|
options: {
|
||||||
},
|
sources: false,
|
||||||
],
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.ts(x?)$/,
|
||||||
|
include: [path.resolve(__dirname, "src")],
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: "esbuild-loader",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
loader: "ifdef-loader", options: {
|
||||||
|
BROWSER: false,
|
||||||
|
MOBILE: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.scss$/,
|
||||||
|
include: [
|
||||||
|
path.resolve(__dirname, "src/assets/scss"),
|
||||||
|
],
|
||||||
|
use: [
|
||||||
|
MiniCssExtractPlugin.loader,
|
||||||
|
{
|
||||||
|
loader: "css-loader", // translates CSS into CommonJS
|
||||||
|
},
|
||||||
|
{
|
||||||
|
loader: "sass-loader", // compiles Sass to CSS
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.woff$/,
|
||||||
|
type: "asset/resource",
|
||||||
|
generator: {
|
||||||
|
filename: "../fonts/JetBrainsMono-Regular.woff",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(png|svg)$/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: "file-loader",
|
||||||
|
options: {
|
||||||
|
name: "[name].[ext]",
|
||||||
|
outputPath: "../../",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
plugins: [
|
||||||
},
|
new CleanWebpackPlugin({
|
||||||
plugins: [
|
cleanStaleWebpackAssets: false,
|
||||||
new CleanWebpackPlugin({
|
cleanOnceBeforeBuildPatterns: [
|
||||||
cleanStaleWebpackAssets: false,
|
path.join(__dirname, "stage/build/app")],
|
||||||
cleanOnceBeforeBuildPatterns: [
|
}),
|
||||||
path.join(__dirname, "stage/build/app")],
|
new webpack.DefinePlugin({
|
||||||
}),
|
SIYUAN_VERSION: JSON.stringify(pkg.version),
|
||||||
new webpack.DefinePlugin({
|
NODE_ENV: JSON.stringify(argv.mode),
|
||||||
SIYUAN_VERSION: JSON.stringify(pkg.version),
|
}),
|
||||||
NODE_ENV: JSON.stringify(argv.mode),
|
new MiniCssExtractPlugin({
|
||||||
}),
|
filename: "base.[contenthash].css",
|
||||||
new MiniCssExtractPlugin({
|
}),
|
||||||
filename: "base.[contenthash].css",
|
new HtmlWebpackPlugin({
|
||||||
}),
|
inject: "head",
|
||||||
new HtmlWebpackPlugin({
|
chunks: ["main"],
|
||||||
inject: "head",
|
filename: "index.html",
|
||||||
chunks: ["main"],
|
template: "src/assets/template/app/index.tpl",
|
||||||
filename: "index.html",
|
}),
|
||||||
template: "src/assets/template/app/index.tpl",
|
new HtmlWebpackPlugin({
|
||||||
}),
|
inject: "head",
|
||||||
new HtmlWebpackPlugin({
|
chunks: ["window"],
|
||||||
inject: "head",
|
filename: "window.html",
|
||||||
chunks: ["window"],
|
template: "src/assets/template/app/window.tpl",
|
||||||
filename: "window.html",
|
}),
|
||||||
template: "src/assets/template/app/window.tpl",
|
],
|
||||||
}),
|
};
|
||||||
],
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,117 +5,117 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||||
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
|
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
|
||||||
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
||||||
const { EsbuildPlugin } = require("esbuild-loader");
|
const {EsbuildPlugin} = require("esbuild-loader");
|
||||||
|
|
||||||
module.exports = (env, argv) => {
|
module.exports = (env, argv) => {
|
||||||
return {
|
return {
|
||||||
mode: argv.mode || "development",
|
mode: argv.mode || "development",
|
||||||
watch: argv.mode !== "production",
|
watch: argv.mode !== "production",
|
||||||
devtool: argv.mode !== "production" ? "eval" : false,
|
devtool: argv.mode !== "production" ? "eval" : false,
|
||||||
output: {
|
output: {
|
||||||
publicPath: "",
|
publicPath: "auto",
|
||||||
filename: "[name].[chunkhash].js",
|
filename: "[name].[chunkhash].js",
|
||||||
path: path.resolve(__dirname, "stage/build/desktop"),
|
path: path.resolve(__dirname, "stage/build/desktop"),
|
||||||
},
|
|
||||||
entry: {
|
|
||||||
"main": "./src/index.ts",
|
|
||||||
},
|
|
||||||
optimization: {
|
|
||||||
minimize: true,
|
|
||||||
minimizer: [
|
|
||||||
new EsbuildPlugin(),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
fallback: {
|
|
||||||
"path": require.resolve("path-browserify"),
|
|
||||||
},
|
|
||||||
extensions: [".ts", ".js", ".tpl", ".scss"],
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.tpl/,
|
|
||||||
include: [
|
|
||||||
path.resolve(__dirname, "src/assets/template/desktop/index.tpl")],
|
|
||||||
loader: "html-loader",
|
|
||||||
options: {
|
|
||||||
sources: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
entry: {
|
||||||
test: /\.ts(x?)$/,
|
"main": "./src/index.ts",
|
||||||
include: [path.resolve(__dirname, "src")],
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: "esbuild-loader",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: "ifdef-loader",
|
|
||||||
options: {
|
|
||||||
"ifdef-verbose": false,
|
|
||||||
BROWSER: true,
|
|
||||||
MOBILE: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
optimization: {
|
||||||
test: /\.scss$/,
|
minimize: true,
|
||||||
include: [
|
minimizer: [
|
||||||
path.resolve(__dirname, "src/assets/scss"),
|
new EsbuildPlugin(),
|
||||||
],
|
],
|
||||||
use: [
|
|
||||||
MiniCssExtractPlugin.loader,
|
|
||||||
{
|
|
||||||
loader: "css-loader", // translates CSS into CommonJS
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: "sass-loader", // compiles Sass to CSS
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
resolve: {
|
||||||
test: /\.woff$/,
|
fallback: {
|
||||||
type: "asset/resource",
|
"path": require.resolve("path-browserify"),
|
||||||
generator: {
|
|
||||||
filename: "../fonts/JetBrainsMono-Regular.woff",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.(png|svg)$/,
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: "file-loader",
|
|
||||||
options: {
|
|
||||||
name: "[name].[ext]",
|
|
||||||
outputPath: "../../",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
extensions: [".ts", ".js", ".tpl", ".scss"],
|
||||||
},
|
},
|
||||||
],
|
module: {
|
||||||
},
|
rules: [
|
||||||
plugins: [
|
{
|
||||||
// new BundleAnalyzerPlugin(),
|
test: /\.tpl/,
|
||||||
new CleanWebpackPlugin({
|
include: [
|
||||||
cleanStaleWebpackAssets: false,
|
path.resolve(__dirname, "src/assets/template/desktop/index.tpl")],
|
||||||
cleanOnceBeforeBuildPatterns: [
|
loader: "html-loader",
|
||||||
path.join(__dirname, "stage/build/desktop")],
|
options: {
|
||||||
}),
|
sources: false,
|
||||||
new webpack.DefinePlugin({
|
},
|
||||||
SIYUAN_VERSION: JSON.stringify(pkg.version),
|
},
|
||||||
NODE_ENV: JSON.stringify(argv.mode),
|
{
|
||||||
}),
|
test: /\.ts(x?)$/,
|
||||||
new MiniCssExtractPlugin({
|
include: [path.resolve(__dirname, "src")],
|
||||||
filename: "base.[contenthash].css",
|
use: [
|
||||||
}),
|
{
|
||||||
new HtmlWebpackPlugin({
|
loader: "esbuild-loader",
|
||||||
inject: "head",
|
},
|
||||||
chunks: ["main"],
|
{
|
||||||
filename: "index.html",
|
loader: "ifdef-loader",
|
||||||
template: "src/assets/template/desktop/index.tpl",
|
options: {
|
||||||
}),
|
"ifdef-verbose": false,
|
||||||
],
|
BROWSER: true,
|
||||||
};
|
MOBILE: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.scss$/,
|
||||||
|
include: [
|
||||||
|
path.resolve(__dirname, "src/assets/scss"),
|
||||||
|
],
|
||||||
|
use: [
|
||||||
|
MiniCssExtractPlugin.loader,
|
||||||
|
{
|
||||||
|
loader: "css-loader", // translates CSS into CommonJS
|
||||||
|
},
|
||||||
|
{
|
||||||
|
loader: "sass-loader", // compiles Sass to CSS
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.woff$/,
|
||||||
|
type: "asset/resource",
|
||||||
|
generator: {
|
||||||
|
filename: "../fonts/JetBrainsMono-Regular.woff",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(png|svg)$/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: "file-loader",
|
||||||
|
options: {
|
||||||
|
name: "[name].[ext]",
|
||||||
|
outputPath: "../../",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// new BundleAnalyzerPlugin(),
|
||||||
|
new CleanWebpackPlugin({
|
||||||
|
cleanStaleWebpackAssets: false,
|
||||||
|
cleanOnceBeforeBuildPatterns: [
|
||||||
|
path.join(__dirname, "stage/build/desktop")],
|
||||||
|
}),
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
SIYUAN_VERSION: JSON.stringify(pkg.version),
|
||||||
|
NODE_ENV: JSON.stringify(argv.mode),
|
||||||
|
}),
|
||||||
|
new MiniCssExtractPlugin({
|
||||||
|
filename: "base.[contenthash].css",
|
||||||
|
}),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
inject: "head",
|
||||||
|
chunks: ["main"],
|
||||||
|
filename: "index.html",
|
||||||
|
template: "src/assets/template/desktop/index.tpl",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,92 +4,92 @@ const pkg = require("./package.json");
|
||||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||||
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
|
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
|
||||||
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
||||||
const { EsbuildPlugin } = require("esbuild-loader");
|
const {EsbuildPlugin} = require("esbuild-loader");
|
||||||
|
|
||||||
module.exports = (env, argv) => {
|
module.exports = (env, argv) => {
|
||||||
return {
|
return {
|
||||||
mode: argv.mode || "development",
|
mode: argv.mode || "development",
|
||||||
watch: argv.mode !== "production",
|
watch: argv.mode !== "production",
|
||||||
devtool: argv.mode !== "production" ? "eval" : false,
|
devtool: argv.mode !== "production" ? "eval" : false,
|
||||||
output: {
|
output: {
|
||||||
publicPath: "",
|
publicPath: "auto",
|
||||||
filename: "[name].js",
|
filename: "[name].js",
|
||||||
path: path.resolve(__dirname, "stage/build/export"),
|
path: path.resolve(__dirname, "stage/build/export"),
|
||||||
libraryTarget: "umd",
|
libraryTarget: "umd",
|
||||||
library: "Protyle",
|
library: "Protyle",
|
||||||
libraryExport: "default",
|
libraryExport: "default",
|
||||||
},
|
|
||||||
entry: {
|
|
||||||
"protyle-method": "./src/protyle/method.ts",
|
|
||||||
},
|
|
||||||
optimization: {
|
|
||||||
minimize: true,
|
|
||||||
minimizer: [
|
|
||||||
new EsbuildPlugin(),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
fallback: {
|
|
||||||
"path": require.resolve("path-browserify"),
|
|
||||||
},
|
|
||||||
extensions: [".ts", ".js", ".scss"],
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.ts(x?)$/,
|
|
||||||
include: [path.resolve(__dirname, "src")],
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: "esbuild-loader",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: "ifdef-loader",
|
|
||||||
options: {
|
|
||||||
"ifdef-verbose": false,
|
|
||||||
BROWSER: true,
|
|
||||||
MOBILE: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
entry: {
|
||||||
test: /\.scss$/,
|
"protyle-method": "./src/protyle/method.ts",
|
||||||
include: [
|
|
||||||
path.resolve(__dirname, "src/assets/scss"),
|
|
||||||
],
|
|
||||||
use: [
|
|
||||||
MiniCssExtractPlugin.loader,
|
|
||||||
{
|
|
||||||
loader: "css-loader", // translates CSS into CommonJS
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: "sass-loader", // compiles Sass to CSS
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
optimization: {
|
||||||
test: /\.woff$/,
|
minimize: true,
|
||||||
type: "asset/resource",
|
minimizer: [
|
||||||
generator: {
|
new EsbuildPlugin(),
|
||||||
filename: "../fonts/JetBrainsMono-Regular.woff",
|
],
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
resolve: {
|
||||||
},
|
fallback: {
|
||||||
plugins: [
|
"path": require.resolve("path-browserify"),
|
||||||
// new BundleAnalyzerPlugin(),
|
},
|
||||||
new CleanWebpackPlugin({
|
extensions: [".ts", ".js", ".scss"],
|
||||||
cleanOnceBeforeBuildPatterns: [
|
},
|
||||||
path.join(__dirname, "stage/build/export")],
|
module: {
|
||||||
}),
|
rules: [
|
||||||
new webpack.DefinePlugin({
|
{
|
||||||
NODE_ENV: JSON.stringify(argv.mode),
|
test: /\.ts(x?)$/,
|
||||||
SIYUAN_VERSION: JSON.stringify(pkg.version),
|
include: [path.resolve(__dirname, "src")],
|
||||||
}),
|
use: [
|
||||||
new MiniCssExtractPlugin({
|
{
|
||||||
filename: "base.css",
|
loader: "esbuild-loader",
|
||||||
}),
|
},
|
||||||
],
|
{
|
||||||
};
|
loader: "ifdef-loader",
|
||||||
|
options: {
|
||||||
|
"ifdef-verbose": false,
|
||||||
|
BROWSER: true,
|
||||||
|
MOBILE: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.scss$/,
|
||||||
|
include: [
|
||||||
|
path.resolve(__dirname, "src/assets/scss"),
|
||||||
|
],
|
||||||
|
use: [
|
||||||
|
MiniCssExtractPlugin.loader,
|
||||||
|
{
|
||||||
|
loader: "css-loader", // translates CSS into CommonJS
|
||||||
|
},
|
||||||
|
{
|
||||||
|
loader: "sass-loader", // compiles Sass to CSS
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.woff$/,
|
||||||
|
type: "asset/resource",
|
||||||
|
generator: {
|
||||||
|
filename: "../fonts/JetBrainsMono-Regular.woff",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// new BundleAnalyzerPlugin(),
|
||||||
|
new CleanWebpackPlugin({
|
||||||
|
cleanOnceBeforeBuildPatterns: [
|
||||||
|
path.join(__dirname, "stage/build/export")],
|
||||||
|
}),
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
NODE_ENV: JSON.stringify(argv.mode),
|
||||||
|
SIYUAN_VERSION: JSON.stringify(pkg.version),
|
||||||
|
}),
|
||||||
|
new MiniCssExtractPlugin({
|
||||||
|
filename: "base.css",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,117 +5,117 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||||
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
|
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
|
||||||
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
||||||
const { EsbuildPlugin } = require("esbuild-loader");
|
const {EsbuildPlugin} = require("esbuild-loader");
|
||||||
|
|
||||||
module.exports = (env, argv) => {
|
module.exports = (env, argv) => {
|
||||||
return {
|
return {
|
||||||
mode: argv.mode || "development",
|
mode: argv.mode || "development",
|
||||||
watch: argv.mode !== "production",
|
watch: argv.mode !== "production",
|
||||||
devtool: argv.mode !== "production" ? "eval" : false,
|
devtool: argv.mode !== "production" ? "eval" : false,
|
||||||
output: {
|
output: {
|
||||||
publicPath: "",
|
publicPath: "auto",
|
||||||
filename: "[name].[chunkhash].js",
|
filename: "[name].[chunkhash].js",
|
||||||
path: path.resolve(__dirname, "stage/build/mobile"),
|
path: path.resolve(__dirname, "stage/build/mobile"),
|
||||||
},
|
|
||||||
entry: {
|
|
||||||
"main": "./src/mobile/index.ts",
|
|
||||||
},
|
|
||||||
optimization: {
|
|
||||||
minimize: true,
|
|
||||||
minimizer: [
|
|
||||||
new EsbuildPlugin(),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
fallback: {
|
|
||||||
"path": require.resolve("path-browserify"),
|
|
||||||
},
|
|
||||||
extensions: [".ts", ".js", ".tpl", ".scss"],
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.tpl/,
|
|
||||||
include: [
|
|
||||||
path.resolve(__dirname, "src/assets/template/mobile/index.tpl")],
|
|
||||||
loader: "html-loader",
|
|
||||||
options: {
|
|
||||||
sources: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
entry: {
|
||||||
test: /\.ts(x?)$/,
|
"main": "./src/mobile/index.ts",
|
||||||
include: [path.resolve(__dirname, "src")],
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: "esbuild-loader",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: "ifdef-loader",
|
|
||||||
options: {
|
|
||||||
"ifdef-verbose": false,
|
|
||||||
BROWSER: true,
|
|
||||||
MOBILE: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
optimization: {
|
||||||
test: /\.scss$/,
|
minimize: true,
|
||||||
include: [
|
minimizer: [
|
||||||
path.resolve(__dirname, "src/assets/scss"),
|
new EsbuildPlugin(),
|
||||||
],
|
],
|
||||||
use: [
|
|
||||||
MiniCssExtractPlugin.loader,
|
|
||||||
{
|
|
||||||
loader: "css-loader", // translates CSS into CommonJS
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: "sass-loader", // compiles Sass to CSS
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
resolve: {
|
||||||
test: /\.woff$/,
|
fallback: {
|
||||||
type: "asset/resource",
|
"path": require.resolve("path-browserify"),
|
||||||
generator: {
|
|
||||||
filename: "../fonts/JetBrainsMono-Regular.woff",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.(png|svg)$/,
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: "file-loader",
|
|
||||||
options: {
|
|
||||||
name: "[name].[ext]",
|
|
||||||
outputPath: "../../",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
extensions: [".ts", ".js", ".tpl", ".scss"],
|
||||||
},
|
},
|
||||||
],
|
module: {
|
||||||
},
|
rules: [
|
||||||
plugins: [
|
{
|
||||||
// new BundleAnalyzerPlugin(),
|
test: /\.tpl/,
|
||||||
new CleanWebpackPlugin({
|
include: [
|
||||||
cleanStaleWebpackAssets: false,
|
path.resolve(__dirname, "src/assets/template/mobile/index.tpl")],
|
||||||
cleanOnceBeforeBuildPatterns: [
|
loader: "html-loader",
|
||||||
path.join(__dirname, "stage/build/mobile")],
|
options: {
|
||||||
}),
|
sources: false,
|
||||||
new webpack.DefinePlugin({
|
},
|
||||||
SIYUAN_VERSION: JSON.stringify(pkg.version),
|
},
|
||||||
NODE_ENV: JSON.stringify(argv.mode),
|
{
|
||||||
}),
|
test: /\.ts(x?)$/,
|
||||||
new MiniCssExtractPlugin({
|
include: [path.resolve(__dirname, "src")],
|
||||||
filename: "base.[contenthash].css",
|
use: [
|
||||||
}),
|
{
|
||||||
new HtmlWebpackPlugin({
|
loader: "esbuild-loader",
|
||||||
inject: "head",
|
},
|
||||||
chunks: ["main"],
|
{
|
||||||
filename: "index.html",
|
loader: "ifdef-loader",
|
||||||
template: "src/assets/template/mobile/index.tpl",
|
options: {
|
||||||
}),
|
"ifdef-verbose": false,
|
||||||
],
|
BROWSER: true,
|
||||||
};
|
MOBILE: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.scss$/,
|
||||||
|
include: [
|
||||||
|
path.resolve(__dirname, "src/assets/scss"),
|
||||||
|
],
|
||||||
|
use: [
|
||||||
|
MiniCssExtractPlugin.loader,
|
||||||
|
{
|
||||||
|
loader: "css-loader", // translates CSS into CommonJS
|
||||||
|
},
|
||||||
|
{
|
||||||
|
loader: "sass-loader", // compiles Sass to CSS
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.woff$/,
|
||||||
|
type: "asset/resource",
|
||||||
|
generator: {
|
||||||
|
filename: "../fonts/JetBrainsMono-Regular.woff",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(png|svg)$/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: "file-loader",
|
||||||
|
options: {
|
||||||
|
name: "[name].[ext]",
|
||||||
|
outputPath: "../../",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// new BundleAnalyzerPlugin(),
|
||||||
|
new CleanWebpackPlugin({
|
||||||
|
cleanStaleWebpackAssets: false,
|
||||||
|
cleanOnceBeforeBuildPatterns: [
|
||||||
|
path.join(__dirname, "stage/build/mobile")],
|
||||||
|
}),
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
SIYUAN_VERSION: JSON.stringify(pkg.version),
|
||||||
|
NODE_ENV: JSON.stringify(argv.mode),
|
||||||
|
}),
|
||||||
|
new MiniCssExtractPlugin({
|
||||||
|
filename: "base.[contenthash].css",
|
||||||
|
}),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
inject: "head",
|
||||||
|
chunks: ["main"],
|
||||||
|
filename: "index.html",
|
||||||
|
template: "src/assets/template/mobile/index.tpl",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue