eslint js 文件并启用缓存 --cache
(#7330)
* chore: lint js file and use cache to speed up * chore: autofix and format code
This commit is contained in:
parent
9680294d39
commit
ab15c09e26
12 changed files with 207 additions and 207 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,6 +7,7 @@
|
|||
*.jar
|
||||
*.syso
|
||||
.DS_Store
|
||||
.eslintcache
|
||||
app/node_modules
|
||||
app/stage/build
|
||||
app/build
|
||||
|
|
|
@ -3,4 +3,6 @@ dist
|
|||
electron
|
||||
node_modules
|
||||
public
|
||||
*.js
|
||||
src/asset/pdf
|
||||
stage
|
||||
appearance
|
||||
|
|
|
@ -1,23 +1,24 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
parser: '@typescript-eslint/parser',
|
||||
env: { node: true, browser: true, es6: true },
|
||||
parser: "@typescript-eslint/parser",
|
||||
plugins: [
|
||||
'@typescript-eslint',
|
||||
"@typescript-eslint",
|
||||
],
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
],
|
||||
rules: {
|
||||
semi: [2, 'always'],
|
||||
quotes: [2, 'double', {'avoidEscape': true}],
|
||||
'no-prototype-builtins': 'off',
|
||||
'no-useless-escape': 'off',
|
||||
'no-irregular-whitespace': 'off',
|
||||
'@typescript-eslint/ban-ts-comment': 'off',
|
||||
'@typescript-eslint/no-var-requires': 'off',
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
semi: [2, "always"],
|
||||
quotes: [2, "double", {"avoidEscape": true}],
|
||||
"no-prototype-builtins": "off",
|
||||
"no-useless-escape": "off",
|
||||
"no-irregular-whitespace": "off",
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
"@typescript-eslint/no-var-requires": "off",
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"main": "./electron/main.js",
|
||||
"packageManager": "pnpm@7.26.1",
|
||||
"scripts": {
|
||||
"lint": "eslint . --fix --ext .ts",
|
||||
"lint": "eslint . --fix --cache",
|
||||
"dev": "webpack --mode development",
|
||||
"dev:mobile": "webpack --mode development --config webpack.mobile.js",
|
||||
"dev:desktop": "webpack --mode development --config webpack.desktop.js",
|
||||
|
|
|
@ -410,7 +410,7 @@ export const updateFileTreeEmoji = (unicode: string, id: string, icon = "iconFil
|
|||
/// #if MOBILE
|
||||
emojiElement = document.querySelector(`#sidebar [data-type="sidebar-file"] [data-node-id="${id}"] .b3-list-item__icon`);
|
||||
/// #else
|
||||
const dockFile = getDockByType("file")
|
||||
const dockFile = getDockByType("file");
|
||||
if (dockFile) {
|
||||
const files = dockFile.data.file as Files;
|
||||
if (icon === "iconFile") {
|
||||
|
|
|
@ -1478,7 +1478,7 @@ export class WYSIWYG {
|
|||
let shiftStartElement: HTMLElement;
|
||||
this.element.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
|
||||
hideElements(["hint", "util"], protyle);
|
||||
const ctrlIsPressed = event.metaKey || event.ctrlKey
|
||||
const ctrlIsPressed = event.metaKey || event.ctrlKey;
|
||||
/// #if !MOBILE
|
||||
const backlinkBreadcrumbItemElement = hasClosestByClassName(event.target, "protyle-breadcrumb__item");
|
||||
if (backlinkBreadcrumbItemElement) {
|
||||
|
|
|
@ -903,19 +903,19 @@ const updateConfig = (element: Element, item: ISearchOption, config: ISearchOpti
|
|||
}
|
||||
(element.querySelector("#searchInput") as HTMLInputElement).value = item.k;
|
||||
(element.querySelector("#replaceInput") as HTMLInputElement).value = item.r;
|
||||
let methodTip = window.siyuan.languages.searchMethod + " "
|
||||
let methodTip = window.siyuan.languages.searchMethod + " ";
|
||||
switch (item.method) {
|
||||
case 0:
|
||||
methodTip += window.siyuan.languages.keyword;
|
||||
break;
|
||||
case 1:
|
||||
methodTip += window.siyuan.languages.querySyntax
|
||||
methodTip += window.siyuan.languages.querySyntax;
|
||||
break;
|
||||
case 2:
|
||||
methodTip += "SQL"
|
||||
methodTip += "SQL";
|
||||
break;
|
||||
case 3:
|
||||
methodTip += window.siyuan.languages.regex
|
||||
methodTip += window.siyuan.languages.regex;
|
||||
break;
|
||||
}
|
||||
element.querySelector("#searchSyntaxCheck").setAttribute("aria-label", methodTip);
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
const pkg = require('./package.json')
|
||||
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
|
||||
const BundleAnalyzerPlugin = require(
|
||||
'webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||
const TerserPlugin = require('terser-webpack-plugin')
|
||||
const path = require("path");
|
||||
const webpack = require("webpack");
|
||||
const pkg = require("./package.json");
|
||||
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
|
||||
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
|
||||
module.exports = (env, argv) => {
|
||||
return {
|
||||
mode: argv.mode || 'development',
|
||||
watch: argv.mode !== 'production',
|
||||
devtool: argv.mode !== 'production' ? 'eval' : false,
|
||||
mode: argv.mode || "development",
|
||||
watch: argv.mode !== "production",
|
||||
devtool: argv.mode !== "production" ? "eval" : false,
|
||||
output: {
|
||||
publicPath: "",
|
||||
filename: '[name].js',
|
||||
path: path.resolve(__dirname, 'stage/build/api'),
|
||||
libraryTarget: 'umd',
|
||||
library: 'SiYuanAPI',
|
||||
libraryExport: 'default',
|
||||
filename: "[name].js",
|
||||
path: path.resolve(__dirname, "stage/build/api"),
|
||||
libraryTarget: "umd",
|
||||
library: "SiYuanAPI",
|
||||
libraryExport: "default",
|
||||
},
|
||||
entry: {
|
||||
'api': './src/api.ts',
|
||||
"api": "./src/api.ts",
|
||||
},
|
||||
optimization: {
|
||||
minimize: true,
|
||||
|
@ -37,23 +36,23 @@ module.exports = (env, argv) => {
|
|||
},
|
||||
resolve: {
|
||||
fallback: {
|
||||
'path': require.resolve('path-browserify'),
|
||||
"path": require.resolve("path-browserify"),
|
||||
},
|
||||
extensions: ['.ts', '.js', '.scss'],
|
||||
extensions: [".ts", ".js", ".scss"],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts(x?)$/,
|
||||
include: [path.resolve(__dirname, 'src')],
|
||||
include: [path.resolve(__dirname, "src")],
|
||||
use: [
|
||||
{
|
||||
loader: 'ts-loader',
|
||||
loader: "ts-loader",
|
||||
},
|
||||
{
|
||||
loader: 'ifdef-loader',
|
||||
loader: "ifdef-loader",
|
||||
options: {
|
||||
'ifdef-verbose': false,
|
||||
"ifdef-verbose": false,
|
||||
BROWSER: true,
|
||||
MOBILE: true,
|
||||
},
|
||||
|
@ -66,12 +65,12 @@ module.exports = (env, argv) => {
|
|||
// new BundleAnalyzerPlugin(),
|
||||
new CleanWebpackPlugin({
|
||||
cleanOnceBeforeBuildPatterns: [
|
||||
path.join(__dirname, 'stage/build/api')],
|
||||
path.join(__dirname, "stage/build/api")],
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
NODE_ENV: JSON.stringify(argv.mode),
|
||||
SIYUAN_VERSION: JSON.stringify(pkg.version),
|
||||
}),
|
||||
],
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
const pkg = require('./package.json')
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
|
||||
const TerserPlugin = require('terser-webpack-plugin')
|
||||
const path = require("path");
|
||||
const webpack = require("webpack");
|
||||
const pkg = require("./package.json");
|
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
|
||||
module.exports = (env, argv) => {
|
||||
return {
|
||||
mode: argv.mode || 'development',
|
||||
watch: argv.mode !== 'production',
|
||||
devtool: argv.mode !== 'production' ? 'eval' : false,
|
||||
target: 'electron-renderer',
|
||||
mode: argv.mode || "development",
|
||||
watch: argv.mode !== "production",
|
||||
devtool: argv.mode !== "production" ? "eval" : false,
|
||||
target: "electron-renderer",
|
||||
output: {
|
||||
publicPath: '',
|
||||
filename: '[name].[chunkhash].js',
|
||||
path: path.resolve(__dirname, 'stage/build/app'),
|
||||
publicPath: "",
|
||||
filename: "[name].[chunkhash].js",
|
||||
path: path.resolve(__dirname, "stage/build/app"),
|
||||
},
|
||||
entry: {
|
||||
'main': './src/index.ts',
|
||||
'window': './src/window/index.ts',
|
||||
"main": "./src/index.ts",
|
||||
"window": "./src/window/index.ts",
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.js', '.tpl', '.scss', '.png', '.svg'],
|
||||
extensions: [".ts", ".js", ".tpl", ".scss", ".png", ".svg"],
|
||||
},
|
||||
optimization: {
|
||||
minimize: true,
|
||||
|
@ -42,22 +42,22 @@ module.exports = (env, argv) => {
|
|||
{
|
||||
test: /\.tpl/,
|
||||
include: [
|
||||
path.resolve(__dirname, 'src/assets/template/app/index.tpl'),
|
||||
path.resolve(__dirname, 'src/assets/template/app/window.tpl')],
|
||||
loader: 'html-loader',
|
||||
path.resolve(__dirname, "src/assets/template/app/index.tpl"),
|
||||
path.resolve(__dirname, "src/assets/template/app/window.tpl")],
|
||||
loader: "html-loader",
|
||||
options: {
|
||||
sources: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.ts(x?)$/,
|
||||
include: [path.resolve(__dirname, 'src')],
|
||||
include: [path.resolve(__dirname, "src")],
|
||||
use: [
|
||||
{
|
||||
loader: 'ts-loader',
|
||||
loader: "ts-loader",
|
||||
},
|
||||
{
|
||||
loader: 'ifdef-loader', options: {
|
||||
loader: "ifdef-loader", options: {
|
||||
BROWSER: false,
|
||||
MOBILE: false,
|
||||
},
|
||||
|
@ -67,33 +67,33 @@ module.exports = (env, argv) => {
|
|||
{
|
||||
test: /\.scss$/,
|
||||
include: [
|
||||
path.resolve(__dirname, 'src/assets/scss'),
|
||||
path.resolve(__dirname, "src/assets/scss"),
|
||||
],
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
{
|
||||
loader: 'css-loader', // translates CSS into CommonJS
|
||||
loader: "css-loader", // translates CSS into CommonJS
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader', // compiles Sass to CSS
|
||||
loader: "sass-loader", // compiles Sass to CSS
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.woff$/,
|
||||
type: 'asset/resource',
|
||||
type: "asset/resource",
|
||||
generator: {
|
||||
filename: '../fonts/JetBrainsMono-Regular.woff',
|
||||
filename: "../fonts/JetBrainsMono-Regular.woff",
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.(png|svg)$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'file-loader',
|
||||
loader: "file-loader",
|
||||
options: {
|
||||
name: '[name].[ext]',
|
||||
outputPath: '../../',
|
||||
name: "[name].[ext]",
|
||||
outputPath: "../../",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -104,27 +104,27 @@ module.exports = (env, argv) => {
|
|||
new CleanWebpackPlugin({
|
||||
cleanStaleWebpackAssets: false,
|
||||
cleanOnceBeforeBuildPatterns: [
|
||||
path.join(__dirname, 'stage/build/app')],
|
||||
path.join(__dirname, "stage/build/app")],
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
SIYUAN_VERSION: JSON.stringify(pkg.version),
|
||||
NODE_ENV: JSON.stringify(argv.mode),
|
||||
}),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: 'base.[contenthash].css',
|
||||
filename: "base.[contenthash].css",
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
inject: 'head',
|
||||
chunks: ['main'],
|
||||
filename: 'index.html',
|
||||
template: 'src/assets/template/app/index.tpl',
|
||||
inject: "head",
|
||||
chunks: ["main"],
|
||||
filename: "index.html",
|
||||
template: "src/assets/template/app/index.tpl",
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
inject: 'head',
|
||||
chunks: ['window'],
|
||||
filename: 'window.html',
|
||||
template: 'src/assets/template/app/window.tpl',
|
||||
inject: "head",
|
||||
chunks: ["window"],
|
||||
filename: "window.html",
|
||||
template: "src/assets/template/app/window.tpl",
|
||||
}),
|
||||
],
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
const pkg = require('./package.json')
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
|
||||
const BundleAnalyzerPlugin = require(
|
||||
'webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||
const TerserPlugin = require('terser-webpack-plugin')
|
||||
const path = require("path");
|
||||
const webpack = require("webpack");
|
||||
const pkg = require("./package.json");
|
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
|
||||
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
|
||||
module.exports = (env, argv) => {
|
||||
return {
|
||||
mode: argv.mode || 'development',
|
||||
watch: argv.mode !== 'production',
|
||||
devtool: argv.mode !== 'production' ? 'eval' : false,
|
||||
mode: argv.mode || "development",
|
||||
watch: argv.mode !== "production",
|
||||
devtool: argv.mode !== "production" ? "eval" : false,
|
||||
output: {
|
||||
publicPath: '',
|
||||
filename: '[name].[chunkhash].js',
|
||||
path: path.resolve(__dirname, 'stage/build/desktop'),
|
||||
publicPath: "",
|
||||
filename: "[name].[chunkhash].js",
|
||||
path: path.resolve(__dirname, "stage/build/desktop"),
|
||||
},
|
||||
entry: {
|
||||
'main': './src/index.ts',
|
||||
"main": "./src/index.ts",
|
||||
},
|
||||
optimization: {
|
||||
minimize: true,
|
||||
|
@ -36,31 +35,31 @@ module.exports = (env, argv) => {
|
|||
},
|
||||
resolve: {
|
||||
fallback: {
|
||||
'path': require.resolve('path-browserify'),
|
||||
"path": require.resolve("path-browserify"),
|
||||
},
|
||||
extensions: ['.ts', '.js', '.tpl', '.scss'],
|
||||
extensions: [".ts", ".js", ".tpl", ".scss"],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tpl/,
|
||||
include: [
|
||||
path.resolve(__dirname, 'src/assets/template/desktop/index.tpl')],
|
||||
loader: 'html-loader',
|
||||
path.resolve(__dirname, "src/assets/template/desktop/index.tpl")],
|
||||
loader: "html-loader",
|
||||
options: {
|
||||
sources: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
include: [path.resolve(__dirname, 'src/asset/pdf')],
|
||||
include: [path.resolve(__dirname, "src/asset/pdf")],
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
loader: "babel-loader",
|
||||
options: {
|
||||
presets: ['@babel/preset-env'],
|
||||
presets: ["@babel/preset-env"],
|
||||
plugins: [
|
||||
[
|
||||
'@babel/plugin-transform-runtime',
|
||||
"@babel/plugin-transform-runtime",
|
||||
{
|
||||
helpers: false,
|
||||
regenerator: true,
|
||||
|
@ -72,15 +71,15 @@ module.exports = (env, argv) => {
|
|||
},
|
||||
{
|
||||
test: /\.ts(x?)$/,
|
||||
include: [path.resolve(__dirname, 'src')],
|
||||
include: [path.resolve(__dirname, "src")],
|
||||
use: [
|
||||
{
|
||||
loader: 'ts-loader',
|
||||
loader: "ts-loader",
|
||||
},
|
||||
{
|
||||
loader: 'ifdef-loader',
|
||||
loader: "ifdef-loader",
|
||||
options: {
|
||||
'ifdef-verbose': false,
|
||||
"ifdef-verbose": false,
|
||||
BROWSER: true,
|
||||
MOBILE: false,
|
||||
},
|
||||
|
@ -90,33 +89,33 @@ module.exports = (env, argv) => {
|
|||
{
|
||||
test: /\.scss$/,
|
||||
include: [
|
||||
path.resolve(__dirname, 'src/assets/scss'),
|
||||
path.resolve(__dirname, "src/assets/scss"),
|
||||
],
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
{
|
||||
loader: 'css-loader', // translates CSS into CommonJS
|
||||
loader: "css-loader", // translates CSS into CommonJS
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader', // compiles Sass to CSS
|
||||
loader: "sass-loader", // compiles Sass to CSS
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.woff$/,
|
||||
type: 'asset/resource',
|
||||
type: "asset/resource",
|
||||
generator: {
|
||||
filename: '../fonts/JetBrainsMono-Regular.woff',
|
||||
filename: "../fonts/JetBrainsMono-Regular.woff",
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.(png|svg)$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'file-loader',
|
||||
loader: "file-loader",
|
||||
options: {
|
||||
name: '[name].[ext]',
|
||||
outputPath: '../../',
|
||||
name: "[name].[ext]",
|
||||
outputPath: "../../",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -128,21 +127,21 @@ module.exports = (env, argv) => {
|
|||
new CleanWebpackPlugin({
|
||||
cleanStaleWebpackAssets: false,
|
||||
cleanOnceBeforeBuildPatterns: [
|
||||
path.join(__dirname, 'stage/build/desktop')],
|
||||
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',
|
||||
filename: "base.[contenthash].css",
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
inject: 'head',
|
||||
chunks: ['main'],
|
||||
filename: 'index.html',
|
||||
template: 'src/assets/template/desktop/index.tpl',
|
||||
inject: "head",
|
||||
chunks: ["main"],
|
||||
filename: "index.html",
|
||||
template: "src/assets/template/desktop/index.tpl",
|
||||
}),
|
||||
],
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,27 +1,26 @@
|
|||
const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
const pkg = require('./package.json')
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
|
||||
const BundleAnalyzerPlugin = require(
|
||||
'webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||
const TerserPlugin = require('terser-webpack-plugin')
|
||||
const path = require("path");
|
||||
const webpack = require("webpack");
|
||||
const pkg = require("./package.json");
|
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
|
||||
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
|
||||
module.exports = (env, argv) => {
|
||||
return {
|
||||
mode: argv.mode || 'development',
|
||||
watch: argv.mode !== 'production',
|
||||
devtool: argv.mode !== 'production' ? 'eval' : false,
|
||||
mode: argv.mode || "development",
|
||||
watch: argv.mode !== "production",
|
||||
devtool: argv.mode !== "production" ? "eval" : false,
|
||||
output: {
|
||||
publicPath: "",
|
||||
filename: '[name].js',
|
||||
path: path.resolve(__dirname, 'stage/build/export'),
|
||||
libraryTarget: 'umd',
|
||||
library: 'Protyle',
|
||||
libraryExport: 'default',
|
||||
filename: "[name].js",
|
||||
path: path.resolve(__dirname, "stage/build/export"),
|
||||
libraryTarget: "umd",
|
||||
library: "Protyle",
|
||||
libraryExport: "default",
|
||||
},
|
||||
entry: {
|
||||
'protyle-method': './src/protyle/method.ts',
|
||||
"protyle-method": "./src/protyle/method.ts",
|
||||
},
|
||||
optimization: {
|
||||
minimize: true,
|
||||
|
@ -38,23 +37,23 @@ module.exports = (env, argv) => {
|
|||
},
|
||||
resolve: {
|
||||
fallback: {
|
||||
'path': require.resolve('path-browserify'),
|
||||
"path": require.resolve("path-browserify"),
|
||||
},
|
||||
extensions: ['.ts', '.js', '.scss'],
|
||||
extensions: [".ts", ".js", ".scss"],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts(x?)$/,
|
||||
include: [path.resolve(__dirname, 'src')],
|
||||
include: [path.resolve(__dirname, "src")],
|
||||
use: [
|
||||
{
|
||||
loader: 'ts-loader',
|
||||
loader: "ts-loader",
|
||||
},
|
||||
{
|
||||
loader: 'ifdef-loader',
|
||||
loader: "ifdef-loader",
|
||||
options: {
|
||||
'ifdef-verbose': false,
|
||||
"ifdef-verbose": false,
|
||||
BROWSER: true,
|
||||
MOBILE: true,
|
||||
},
|
||||
|
@ -64,23 +63,23 @@ module.exports = (env, argv) => {
|
|||
{
|
||||
test: /\.scss$/,
|
||||
include: [
|
||||
path.resolve(__dirname, 'src/assets/scss'),
|
||||
path.resolve(__dirname, "src/assets/scss"),
|
||||
],
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
{
|
||||
loader: 'css-loader', // translates CSS into CommonJS
|
||||
loader: "css-loader", // translates CSS into CommonJS
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader', // compiles Sass to CSS
|
||||
loader: "sass-loader", // compiles Sass to CSS
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.woff$/,
|
||||
type: 'asset/resource',
|
||||
type: "asset/resource",
|
||||
generator: {
|
||||
filename: '../fonts/JetBrainsMono-Regular.woff',
|
||||
filename: "../fonts/JetBrainsMono-Regular.woff",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -89,15 +88,15 @@ module.exports = (env, argv) => {
|
|||
// new BundleAnalyzerPlugin(),
|
||||
new CleanWebpackPlugin({
|
||||
cleanOnceBeforeBuildPatterns: [
|
||||
path.join(__dirname, 'stage/build/export')],
|
||||
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',
|
||||
filename: "base.css",
|
||||
}),
|
||||
],
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
const pkg = require('./package.json')
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
|
||||
const BundleAnalyzerPlugin = require(
|
||||
'webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||
const TerserPlugin = require('terser-webpack-plugin')
|
||||
const path = require("path");
|
||||
const webpack = require("webpack");
|
||||
const pkg = require("./package.json");
|
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
|
||||
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
|
||||
module.exports = (env, argv) => {
|
||||
return {
|
||||
mode: argv.mode || 'development',
|
||||
watch: argv.mode !== 'production',
|
||||
devtool: argv.mode !== 'production' ? 'eval' : false,
|
||||
mode: argv.mode || "development",
|
||||
watch: argv.mode !== "production",
|
||||
devtool: argv.mode !== "production" ? "eval" : false,
|
||||
output: {
|
||||
publicPath: '',
|
||||
filename: '[name].[chunkhash].js',
|
||||
path: path.resolve(__dirname, 'stage/build/mobile'),
|
||||
publicPath: "",
|
||||
filename: "[name].[chunkhash].js",
|
||||
path: path.resolve(__dirname, "stage/build/mobile"),
|
||||
},
|
||||
entry: {
|
||||
'main': './src/mobile/index.ts',
|
||||
"main": "./src/mobile/index.ts",
|
||||
},
|
||||
optimization: {
|
||||
minimize: true,
|
||||
|
@ -36,32 +35,32 @@ module.exports = (env, argv) => {
|
|||
},
|
||||
resolve: {
|
||||
fallback: {
|
||||
'path': require.resolve('path-browserify'),
|
||||
"path": require.resolve("path-browserify"),
|
||||
},
|
||||
extensions: ['.ts', '.js', '.tpl', '.scss'],
|
||||
extensions: [".ts", ".js", ".tpl", ".scss"],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tpl/,
|
||||
include: [
|
||||
path.resolve(__dirname, 'src/assets/template/mobile/index.tpl')],
|
||||
loader: 'html-loader',
|
||||
path.resolve(__dirname, "src/assets/template/mobile/index.tpl")],
|
||||
loader: "html-loader",
|
||||
options: {
|
||||
sources: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.ts(x?)$/,
|
||||
include: [path.resolve(__dirname, 'src')],
|
||||
include: [path.resolve(__dirname, "src")],
|
||||
use: [
|
||||
{
|
||||
loader: 'ts-loader',
|
||||
loader: "ts-loader",
|
||||
},
|
||||
{
|
||||
loader: 'ifdef-loader',
|
||||
loader: "ifdef-loader",
|
||||
options: {
|
||||
'ifdef-verbose': false,
|
||||
"ifdef-verbose": false,
|
||||
BROWSER: true,
|
||||
MOBILE: true,
|
||||
},
|
||||
|
@ -71,33 +70,33 @@ module.exports = (env, argv) => {
|
|||
{
|
||||
test: /\.scss$/,
|
||||
include: [
|
||||
path.resolve(__dirname, 'src/assets/scss'),
|
||||
path.resolve(__dirname, "src/assets/scss"),
|
||||
],
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
{
|
||||
loader: 'css-loader', // translates CSS into CommonJS
|
||||
loader: "css-loader", // translates CSS into CommonJS
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader', // compiles Sass to CSS
|
||||
loader: "sass-loader", // compiles Sass to CSS
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.woff$/,
|
||||
type: 'asset/resource',
|
||||
type: "asset/resource",
|
||||
generator: {
|
||||
filename: '../fonts/JetBrainsMono-Regular.woff',
|
||||
filename: "../fonts/JetBrainsMono-Regular.woff",
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.(png|svg)$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'file-loader',
|
||||
loader: "file-loader",
|
||||
options: {
|
||||
name: '[name].[ext]',
|
||||
outputPath: '../../',
|
||||
name: "[name].[ext]",
|
||||
outputPath: "../../",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -109,21 +108,21 @@ module.exports = (env, argv) => {
|
|||
new CleanWebpackPlugin({
|
||||
cleanStaleWebpackAssets: false,
|
||||
cleanOnceBeforeBuildPatterns: [
|
||||
path.join(__dirname, 'stage/build/mobile')],
|
||||
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',
|
||||
filename: "base.[contenthash].css",
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
inject: 'head',
|
||||
chunks: ['main'],
|
||||
filename: 'index.html',
|
||||
template: 'src/assets/template/mobile/index.tpl',
|
||||
inject: "head",
|
||||
chunks: ["main"],
|
||||
filename: "index.html",
|
||||
template: "src/assets/template/mobile/index.tpl",
|
||||
}),
|
||||
],
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue