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)$/)