mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 00:50:13 +01:00
This commit is contained in:
parent
41e8fe8c03
commit
ffd94d6b51
9 changed files with 1124 additions and 825 deletions
|
|
@ -5,117 +5,117 @@ 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 { 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].[chunkhash].js",
|
||||
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,
|
||||
},
|
||||
return {
|
||||
mode: argv.mode || "development",
|
||||
watch: argv.mode !== "production",
|
||||
devtool: argv.mode !== "production" ? "eval" : false,
|
||||
output: {
|
||||
publicPath: "auto",
|
||||
filename: "[name].[chunkhash].js",
|
||||
path: path.resolve(__dirname, "stage/build/mobile"),
|
||||
},
|
||||
{
|
||||
test: /\.ts(x?)$/,
|
||||
include: [path.resolve(__dirname, "src")],
|
||||
use: [
|
||||
{
|
||||
loader: "esbuild-loader",
|
||||
},
|
||||
{
|
||||
loader: "ifdef-loader",
|
||||
options: {
|
||||
"ifdef-verbose": false,
|
||||
BROWSER: true,
|
||||
MOBILE: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
entry: {
|
||||
"main": "./src/mobile/index.ts",
|
||||
},
|
||||
{
|
||||
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
|
||||
},
|
||||
],
|
||||
optimization: {
|
||||
minimize: true,
|
||||
minimizer: [
|
||||
new EsbuildPlugin(),
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.woff$/,
|
||||
type: "asset/resource",
|
||||
generator: {
|
||||
filename: "../fonts/JetBrainsMono-Regular.woff",
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.(png|svg)$/,
|
||||
use: [
|
||||
{
|
||||
loader: "file-loader",
|
||||
options: {
|
||||
name: "[name].[ext]",
|
||||
outputPath: "../../",
|
||||
},
|
||||
resolve: {
|
||||
fallback: {
|
||||
"path": require.resolve("path-browserify"),
|
||||
},
|
||||
],
|
||||
extensions: [".ts", ".js", ".tpl", ".scss"],
|
||||
},
|
||||
],
|
||||
},
|
||||
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",
|
||||
}),
|
||||
],
|
||||
};
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tpl/,
|
||||
include: [
|
||||
path.resolve(__dirname, "src/assets/template/mobile/index.tpl")],
|
||||
loader: "html-loader",
|
||||
options: {
|
||||
sources: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.ts(x?)$/,
|
||||
include: [path.resolve(__dirname, "src")],
|
||||
use: [
|
||||
{
|
||||
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",
|
||||
},
|
||||
},
|
||||
{
|
||||
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