Skip to content

Commit 371fd62

Browse files
committed
fix(server): 修复无法更改 output.path 为非 prd 的形式
1 parent 4e4c172 commit 371fd62

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lib/commands/server.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,11 @@ exports.run = function (options) {
171171
var projectInfo = getProjectInfo(req);
172172
var projectName = projectInfo.projectName;
173173
var projectCwd = projectInfo.projectCwd;
174-
var outputDir = 'prd';
174+
var project = Manager.getProject(projectCwd, { cache: false });
175+
var outputDir = project.config._config.output.local.path || 'prd';
175176

176-
if (keys[2] !== outputDir) {
177-
// 非prd资源不做处理
177+
// 非 output.path 下的资源不做处理
178+
if (keys[2] !== sysPath.relative(projectCwd, outputDir)) {
178179
next();
179180
return;
180181
}
@@ -205,7 +206,6 @@ exports.run = function (options) {
205206
return;
206207
}
207208

208-
var project = Manager.getProject(projectCwd, { cache: false });
209209
var nextConfig = void 0;
210210
compiler = project.getServerCompiler(function (config) {
211211
nextConfig = extend({}, config);

src/commands/server.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,11 @@ exports.run = (options) => {
159159
const projectInfo = getProjectInfo(req);
160160
const projectName = projectInfo.projectName;
161161
const projectCwd = projectInfo.projectCwd;
162-
const outputDir = 'prd';
162+
const project = Manager.getProject(projectCwd, { cache: false });
163+
const outputDir = project.config._config.output.local.path || 'prd';
163164

164-
if(keys[2] !== outputDir) { // 非prd资源不做处理
165+
// 非 output.path 下的资源不做处理
166+
if(keys[2] !== sysPath.relative(projectCwd, outputDir)) {
165167
next();
166168
return;
167169
}
@@ -192,7 +194,6 @@ exports.run = (options) => {
192194
return;
193195
}
194196

195-
let project = Manager.getProject(projectCwd, { cache: false });
196197
let nextConfig;
197198
compiler = project.getServerCompiler(function (config) {
198199
nextConfig = extend({}, config);

0 commit comments

Comments
 (0)