From 781e37a54bb6cdc90da35191e85d8c5e388cd403 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 16 Apr 2018 11:03:09 -0400 Subject: [PATCH] fix: prioritize own deps + avoid serving wrong index.html (fix #69) --- lib/dev.js | 4 ++++ lib/webpack/createBaseConfig.js | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/dev.js b/lib/dev.js index 601ff4c2e1..0a0d798b57 100644 --- a/lib/dev.js +++ b/lib/dev.js @@ -90,7 +90,11 @@ module.exports = async function dev (sourceDir, cliOptions = {}) { } }) + const nonExistentDir = path.resolve(__dirname, 'non-existent') await serve({ + // avoid project cwd from being served. Otherwise if the user has index.html + // in cwd it would break the server + content: [nonExistentDir], compiler, host: process.env.DEBUG ? '0.0.0.0' : 'localhost', dev: { logLevel: 'warn' }, diff --git a/lib/webpack/createBaseConfig.js b/lib/webpack/createBaseConfig.js index cd09e2749a..a4b3a61213 100644 --- a/lib/webpack/createBaseConfig.js +++ b/lib/webpack/createBaseConfig.js @@ -44,16 +44,16 @@ module.exports = function createBaseConfig ({ .merge(['.js', '.jsx', '.vue', '.json']) .end() .modules - .add('node_modules') - .add(path.resolve(sourceDir, '../node_modules')) + // prioritize our own .add(path.resolve(__dirname, '../../node_modules')) + .add('node_modules') config.resolveLoader .set('symlinks', true) .modules - .add('node_modules') - .add(path.resolve(sourceDir, '../node_modules')) + // prioritize our own .add(path.resolve(__dirname, '../../node_modules')) + .add('node_modules') config.module .noParse(/^(vue|vue-router|vuex|vuex-router-sync)$/)