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 7, 2024
1 parent 7e2b19e commit aa8d68c
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
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 = {
assetPrefix:
process.env.NODE_ENV === "production" && process.env.GITHUB_ACTIONS
? "/resume/"
: "",
output: "export",
lessLoaderOptions: {
lessOptions: {
Expand All @@ -24,10 +20,13 @@ const nextConfig = {
unoptimized: true,
},
transpilePackages: ["antd"],
webpack: (config) => {
config.plugins.push(new AutoBaseWebpackPlugin());
return config;
env: {
ROUTE_PREFIX: "",
},
// webpack: (config) => {
// config.plugins.push(new AutoBaseWebpackPlugin());
// return config;
// },
// async headers() {
// return [
// {
Expand All @@ -43,4 +42,20 @@ const nextConfig = {
// },
};

// 是否通过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}`;

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

module.exports = withLess(nextConfig);

0 comments on commit aa8d68c

Please sign in to comment.