Spaces:
Running
Running
try conditional basePath
Browse files- next.config.ts +4 -2
next.config.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
import type { NextConfig } from "next";
|
| 2 |
|
|
|
|
|
|
|
| 3 |
const nextConfig: NextConfig = {
|
| 4 |
/* config options here */
|
| 5 |
-
basePath: '/deepsite',
|
| 6 |
webpack(config, options) {
|
| 7 |
const { isServer } = options;
|
| 8 |
config.module.rules.push({
|
|
@@ -14,7 +16,7 @@ const nextConfig: NextConfig = {
|
|
| 14 |
options: {
|
| 15 |
limit: config.inlineImageLimit,
|
| 16 |
fallback: require.resolve("file-loader"),
|
| 17 |
-
publicPath: `${config.assetPrefix || '/deepsite'}/_next/static/images/`,
|
| 18 |
outputPath: `${isServer ? "../" : ""}static/images/`,
|
| 19 |
name: "[name]-[hash].[ext]",
|
| 20 |
esModule: config.esModule || false,
|
|
|
|
| 1 |
import type { NextConfig } from "next";
|
| 2 |
|
| 3 |
+
const isHuggingFaceSpaces = process.env.SPACE_ID || process.env.SPACE_HOST;
|
| 4 |
+
|
| 5 |
const nextConfig: NextConfig = {
|
| 6 |
/* config options here */
|
| 7 |
+
...(isHuggingFaceSpaces ? {} : { basePath: '/deepsite' }),
|
| 8 |
webpack(config, options) {
|
| 9 |
const { isServer } = options;
|
| 10 |
config.module.rules.push({
|
|
|
|
| 16 |
options: {
|
| 17 |
limit: config.inlineImageLimit,
|
| 18 |
fallback: require.resolve("file-loader"),
|
| 19 |
+
publicPath: `${config.assetPrefix || (isHuggingFaceSpaces ? '' : '/deepsite')}/_next/static/images/`,
|
| 20 |
outputPath: `${isServer ? "../" : ""}static/images/`,
|
| 21 |
name: "[name]-[hash].[ext]",
|
| 22 |
esModule: config.esModule || false,
|