Skip to content

Commit

Permalink
🎨 #7770
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Mar 24, 2023
1 parent b0b5d20 commit 7a6ea5f
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 63 deletions.
2 changes: 1 addition & 1 deletion app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"outDir": "./dist/",
"noImplicitAny": true,
"module": "commonjs",
"target": "es2021",
"target": "es6",
"typeRoots": [
"./node_modules/@types"
],
Expand Down
123 changes: 63 additions & 60 deletions app/webpack.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,70 @@ const webpack = require("webpack");
const pkg = require("./package.json");
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const { EsbuildPlugin } = require("esbuild-loader");
const {EsbuildPlugin} = require("esbuild-loader");

module.exports = (env, argv) => {
return {
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",
},
entry: {
"api": "./src/api.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",
return {
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",
},
entry: {
"api": "./src/api.ts",
},
optimization: {
minimize: true,
minimizer: [
new EsbuildPlugin({target: "es6"}),
],
},
resolve: {
fallback: {
"path": require.resolve("path-browserify"),
},
{
loader: "ifdef-loader",
options: {
"ifdef-verbose": false,
BROWSER: true,
MOBILE: true,
},
},
],
}
],
},
plugins: [
// new BundleAnalyzerPlugin(),
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [
path.join(__dirname, "stage/build/api")],
}),
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(argv.mode),
SIYUAN_VERSION: JSON.stringify(pkg.version),
}),
],
};
extensions: [".ts", ".js", ".scss"],
},
module: {
rules: [
{
test: /\.ts(x?)$/,
include: [path.resolve(__dirname, "src")],
use: [
{
loader: "esbuild-loader",
options: {
target: "es6",
}
},
{
loader: "ifdef-loader",
options: {
"ifdef-verbose": false,
BROWSER: true,
MOBILE: true,
},
},
],
}
],
},
plugins: [
// new BundleAnalyzerPlugin(),
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [
path.join(__dirname, "stage/build/api")],
}),
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(argv.mode),
SIYUAN_VERSION: JSON.stringify(pkg.version),
}),
],
};
};
2 changes: 1 addition & 1 deletion app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = (env, argv) => {
optimization: {
minimize: true,
minimizer: [
new EsbuildPlugin(),
new EsbuildPlugin({target: "es2021"}),
],
},
module: {
Expand Down
5 changes: 4 additions & 1 deletion app/webpack.export.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = (env, argv) => {
optimization: {
minimize: true,
minimizer: [
new EsbuildPlugin(),
new EsbuildPlugin({target: "es6"}),
],
},
resolve: {
Expand All @@ -42,6 +42,9 @@ module.exports = (env, argv) => {
use: [
{
loader: "esbuild-loader",
options: {
target: "es6",
}
},
{
loader: "ifdef-loader",
Expand Down

0 comments on commit 7a6ea5f

Please sign in to comment.