Skip to content

Commit

Permalink
feat(build): remove autobase-webpack-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
hankliu62 committed Apr 5, 2024
1 parent d8f842c commit 843a917
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 38 deletions.
66 changes: 33 additions & 33 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require("node:path");
const withLess = require("next-with-less");
// const AutoBaseWebpackPlugin = require("autobase-webpack-plugin");
const AutoBaseWebpackPlugin = require("autobase-webpack-plugin");

/** @type {import('next').NextConfig} */
const nextConfig = {
Expand All @@ -20,26 +20,26 @@ const nextConfig = {
unoptimized: true,
},
transpilePackages: ["antd"],
env: {
ROUTE_PREFIX: "",
}
// webpack: (config) => {
// config.plugins.push(new AutoBaseWebpackPlugin());
// console.log(
// config.output,
// config.plugins.find(function (plugin) {
// return (
// (plugin === null || plugin === void 0
// ? void 0
// : plugin.constructor) &&
// (plugin === null || plugin === void 0
// ? void 0
// : plugin.constructor.name) === "DefinePlugin"
// );
// })
// );
// return config;
// env: {
// ROUTE_PREFIX: "",
// },
webpack: (config) => {
config.plugins.push(new AutoBaseWebpackPlugin());
console.log(
config.output,
config.plugins.find(function (plugin) {
return (
(plugin === null || plugin === void 0
? void 0
: plugin.constructor) &&
(plugin === null || plugin === void 0
? void 0
: plugin.constructor.name) === "DefinePlugin"
);
})
);
return config;
},
// async headers() {
// return [
// {
Expand All @@ -55,20 +55,20 @@ const nextConfig = {
// },
};

// 是否通过github actions部署
const isGithubActions = process.env.GITHUB_ACTIONS || false;
// // 是否通过github actions部署
// const isGithubActions = process.env.GITHUB_ACTIONS || false;

if (isGithubActions) {
const repo = process.env.GITHUB_REPOSITORY.replace(/.*?\//, "");
// 用于为静态资源(如图像、样式表、JavaScript 文件等)设置 URL 前缀
// 这在将应用部署到自定义域名或 CDN 上时特别有用,因为它允许您将静态资源存储在不同的位置
nextConfig.assetPrefix = `/${repo}/`;
// 用于为应用设置基础路径
// 这在将应用部署到子目录下时特别有用,因为它允许您指定应用所在的目录
nextConfig.basePath = `/${repo}`;
nextConfig.env.ROUTE_PREFIX = `/${repo}`;
// if (isGithubActions) {
// const repo = process.env.GITHUB_REPOSITORY.replace(/.*?\//, "");
// // 用于为静态资源(如图像、样式表、JavaScript 文件等)设置 URL 前缀
// // 这在将应用部署到自定义域名或 CDN 上时特别有用,因为它允许您将静态资源存储在不同的位置
// nextConfig.assetPrefix = `/${repo}/`;
// // 用于为应用设置基础路径
// // 这在将应用部署到子目录下时特别有用,因为它允许您指定应用所在的目录
// nextConfig.basePath = `/${repo}`;
// nextConfig.env.ROUTE_PREFIX = `/${repo}`;

console.log("next config:", nextConfig);
}
// console.log("next config:", nextConfig);
// }

module.exports = withLess(nextConfig);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@types/aos": "^3.0.7",
"@types/lodash": "^4.14.195",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"autobase-webpack-plugin": "^0.0.2",
"autobase-webpack-plugin": "^0.0.3",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-jest": "^27.2.2",
"eslint-plugin-jest-dom": "^5.0.1",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1121,10 +1121,10 @@ async-validator@^4.1.0:
resolved "https://registry.npmmirror.com/async-validator/-/async-validator-4.2.5.tgz"
integrity sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==

autobase-webpack-plugin@^0.0.2:
version "0.0.2"
resolved "https://registry.npmmirror.com/autobase-webpack-plugin/-/autobase-webpack-plugin-0.0.2.tgz#8d9256c654ad6e2897dfbb4c4217725a401c25bc"
integrity sha512-mrHPp0AOhREhmtjGtdCoQaxuFppWRtE5VizzbjkN1LUujddzDMp0INBejJGkxlU/Bx35o7eO2OEBn/04snKJqg==
autobase-webpack-plugin@^0.0.3:
version "0.0.3"
resolved "https://registry.npmmirror.com/autobase-webpack-plugin/-/autobase-webpack-plugin-0.0.3.tgz#1195d718c3d0494c4b7b95e722492e6ce4a88e4b"
integrity sha512-M/DsbKODzdzqoOnRs9AQCLxtRZDxLHz1MJ0bgD7rU7og9O03RZvoojJ1Yhmei6g3gYuAfTwh1WYtOn9Dq4u+cA==
dependencies:
cross-env "^7.0.3"
rimraf "^5.0.5"
Expand Down

0 comments on commit 843a917

Please sign in to comment.