diff --git a/lib/dev.js b/lib/dev.js index cfb7dc4bf7..150971d58d 100644 --- a/lib/dev.js +++ b/lib/dev.js @@ -7,6 +7,7 @@ module.exports = async function dev (sourceDir, cliOptions = {}) { const serve = require('webpack-serve') const convert = require('koa-connect') const mount = require('koa-mount') + const range = require('koa-range') const serveStatic = require('koa-static') const history = require('connect-history-api-fallback') @@ -108,6 +109,10 @@ module.exports = async function dev (sourceDir, cliOptions = {}) { port, add: app => { const userPublic = path.resolve(sourceDir, '.vuepress/public') + + // enable range request + app.use(range) + // respect base when serving static files... if (fs.existsSync(userPublic)) { app.use(mount(options.publicPath, serveStatic(userPublic))) diff --git a/package.json b/package.json index 13b6fe28da..37b14853ad 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "js-yaml": "^3.11.0", "koa-connect": "^2.0.1", "koa-mount": "^3.0.0", + "koa-range": "^0.3.0", "koa-static": "^4.0.2", "loader-utils": "^1.1.0", "lodash.throttle": "^4.1.1", diff --git a/yarn.lock b/yarn.lock index 1b3c98886d..6cf9d6296b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5060,6 +5060,12 @@ koa-mount@^3.0.0: debug "^2.6.1" koa-compose "^3.2.1" +koa-range@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/koa-range/-/koa-range-0.3.0.tgz#3588e3496473a839a1bd264d2a42b1d85bd7feac" + dependencies: + stream-slice "^0.1.2" + koa-send@^4.1.3: version "4.1.3" resolved "https://registry.yarnpkg.com/koa-send/-/koa-send-4.1.3.tgz#0822207bbf5253a414c8f1765ebc29fa41353cb6" @@ -7616,6 +7622,10 @@ stream-shift@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952" +stream-slice@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/stream-slice/-/stream-slice-0.1.2.tgz#2dc4f4e1b936fb13f3eb39a2def1932798d07a4b" + strict-uri-encode@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" @@ -8292,7 +8302,7 @@ vue-jest@^2.6.0: tsconfig "^7.0.0" vue-template-es2015-compiler "^1.6.0" -vue-loader@^15.2.1: +vue-loader@^15.2.4: version "15.2.4" resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-15.2.4.tgz#a7b923123d3cf87230a8ff54a1c16d31a6c5dbb4" dependencies: