medusa
medusa copied to clipboard
`npx medusa develop` ignores `serve: false` from medusa-config.js
Bug report
Describe the bug
Starting the admin dashboard and the server in their own processes does not work as stated in the documentation.
If I understand the documentation correctly, this configuration:
{
resolve: "@medusajs/admin",
options: {
serve: false,
autoRebuild: false,
develop: {
open: process.env.OPEN_BROWSER !== "false",
},
},
},
should not start the Webpack dev server that is used for development. But that is exactly what happens.
System information
Medusa version (including plugins): v1.20.6 Node.js version: v20.12.1 Database: Postgres v10.4 (Docker Container) Operating system: maxOS Sonoma 14.3 Browser (if relevant): ---
Steps to reproduce the behavior
-
npx create-medusa-app@latest
- Configure database etc. without Next.js storefront
- Stop the already running dev server
- Open
medusa-config.js
- Configure as described in the additional context
- Make sure
autoRebuild: false
andserve: false
is set
- Make sure
- Execute
yarn run dev
--> The Webpack dev server ist started when executing yarn run dev
Expected behavior
Do not start the Webpack dev server for the Admin Dashboard if serve is set to false in the medusa-config.js. This allows the user to start the dev server as it's own process like the documentation states.
Screenshots
If applicable, add screenshots to help explain your problem
Code snippets
If applicable, add code samples to help explain your problem
Additional context
medusa-config.js
const dotenv = require("dotenv");
let ENV_FILE_NAME = "";
switch (process.env.NODE_ENV) {
case "production":
ENV_FILE_NAME = ".env.production";
break;
case "staging":
ENV_FILE_NAME = ".env.staging";
break;
case "test":
ENV_FILE_NAME = ".env.test";
break;
case "development":
default:
ENV_FILE_NAME = ".env";
break;
}
try {
dotenv.config({ path: process.cwd() + "/" + ENV_FILE_NAME });
} catch (e) {}
// CORS when consuming Medusa from admin
const ADMIN_CORS = process.env.ADMIN_CORS || "http://localhost:7000,http://localhost:7001";
// CORS to avoid issues when consuming Medusa from a client
const STORE_CORS = process.env.STORE_CORS || "http://localhost:8000";
const DATABASE_URL = process.env.DATABASE_URL || "postgres://localhost/medusa-starter-default";
const REDIS_URL = process.env.REDIS_URL || "redis://localhost:6379";
const plugins = [
`medusa-fulfillment-manual`,
`medusa-payment-manual`,
{
resolve: `@medusajs/file-local`,
options: {
upload_dir: "uploads",
},
},
{
resolve: "@medusajs/admin",
/** @type {import('@medusajs/admin').PluginOptions} */
options: {
serve: false,
autoRebuild: false,
develop: {
open: process.env.OPEN_BROWSER !== "false",
},
},
},
];
const modules = {
/*eventBus: {
resolve: "@medusajs/event-bus-redis",
options: {
redisUrl: REDIS_URL
}
},
cacheService: {
resolve: "@medusajs/cache-redis",
options: {
redisUrl: REDIS_URL
}
},*/
};
/** @type {import('@medusajs/medusa').ConfigModule["projectConfig"]} */
const projectConfig = {
jwtSecret: process.env.JWT_SECRET,
cookieSecret: process.env.COOKIE_SECRET,
store_cors: STORE_CORS,
database_url: DATABASE_URL,
admin_cors: ADMIN_CORS,
// Uncomment the following lines to enable REDIS
// redis_url: REDIS_URL
};
/** @type {import('@medusajs/medusa').ConfigModule} */
module.exports = {
projectConfig,
plugins,
modules,
};
package.json
{
"name": "medusa-starter-default",
"version": "0.0.1",
"description": "A starter for Medusa projects.",
"author": "Medusa (https://medusajs.com)",
"license": "MIT",
"keywords": [
"sqlite",
"postgres",
"typescript",
"ecommerce",
"headless",
"medusa"
],
"scripts": {
"clean": "cross-env ./node_modules/.bin/rimraf dist",
"build": "cross-env npm run clean && npm run build:server && npm run build:admin",
"build:server": "cross-env npm run clean && tsc -p tsconfig.server.json",
"build:admin": "cross-env medusa-admin build",
"watch": "cross-env tsc --watch",
"test": "cross-env jest",
"seed": "cross-env medusa seed -f ./data/seed.json",
"start": "cross-env npm run build && medusa start",
"start:custom": "cross-env npm run build && node --preserve-symlinks --trace-warnings index.js",
"dev": "cross-env npm run build:server && medusa develop",
"dev:admin": "medusa-admin develop"
},
"dependencies": {
"@medusajs/admin": "^7.1.14",
"@medusajs/cache-inmemory": "latest",
"@medusajs/cache-redis": "^1.9.1",
"@medusajs/event-bus-local": "latest",
"@medusajs/event-bus-redis": "^1.8.13",
"@medusajs/file-local": "latest",
"@medusajs/medusa": "^1.20.6",
"@tanstack/react-query": "4.22.0",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dotenv": "16.3.1",
"express": "^4.17.2",
"medusa-fulfillment-manual": "latest",
"medusa-interfaces": "latest",
"medusa-payment-manual": "latest",
"medusa-payment-stripe": "latest",
"prism-react-renderer": "^2.0.4",
"typeorm": "^0.3.16"
},
"devDependencies": {
"@babel/cli": "^7.14.3",
"@babel/core": "^7.14.3",
"@babel/preset-typescript": "^7.21.4",
"@medusajs/medusa-cli": "latest",
"@stdlib/number-float64-base-normalize": "0.0.8",
"@types/express": "^4.17.13",
"@types/jest": "^27.4.0",
"@types/mime": "1.3.5",
"@types/node": "^17.0.8",
"babel-preset-medusa-package": "^1.1.19",
"cross-env": "^7.0.3",
"eslint": "^6.8.0",
"jest": "^27.3.1",
"rimraf": "^3.0.2",
"ts-jest": "^27.0.7",
"ts-loader": "^9.2.6",
"typescript": "^4.5.2"
},
"jest": {
"globals": {
"ts-jest": {
"tsconfig": "tsconfig.spec.json"
}
},
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"testPathIgnorePatterns": [
"/node_modules/",
"<rootDir>/node_modules/"
],
"rootDir": "src",
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|js)$",
"transform": {
".ts": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "./coverage",
"testEnvironment": "node"
}
}