Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: plugin public files (close: #1491) #1494

Closed
wants to merge 12 commits into from
Prev Previous commit
Next Next commit
mergeable patterns
  • Loading branch information
shigma committed Mar 30, 2019
commit a46905e2ac802fe10875535f33aa501da5189257
2 changes: 1 addition & 1 deletion packages/@vuepress/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
"@vuepress/plugin-container": "^1.0.0-alpha.44",
"@vuepress/plugin-last-updated": "^1.0.0-alpha.44",
"@vuepress/plugin-register-components": "^1.0.0-alpha.44",
"@vuepress/plugin-public-files": "^1.0.0-alpha.44",
"@vuepress/shared-utils": "^1.0.0-alpha.44",
"autoprefixer": "^7.1.2",
"babel-loader": "^8.0.4",
"cache-loader": "^1.2.2",
"chokidar": "^2.0.3",
"connect-history-api-fallback": "^1.5.0",
"copy-webpack-plugin": "^4.5.1",
"cross-spawn": "^6.0.5",
"css-loader": "^0.28.11",
"file-loader": "^1.1.11",
Expand Down
32 changes: 21 additions & 11 deletions packages/@vuepress/plugin-public-files/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
const { path: { resolve }} = require('@vuepress/shared-utils')
const {
fs: { existsSync },
path: { resolve }
} = require('@vuepress/shared-utils')
const CopyPlugin = require('copy-webpack-plugin')
const mergeable = require('vuepress-mergeable')

module.exports = (patterns = [], context) => ({
module.exports = mergeable((patterns, context) => ({
name: `@vuepress/plugin-public-files`,

multiple: true,

chainWebpack (config) {
if (!Array.isArray(patterns)) patterns = [patterns]

config
.plugin('copy')
.use(CopyPlugin, [patterns.map((pattern) => {
if (typeof pattern === 'string') {
pattern = { from: pattern }
} else {
pattern = { ...pattern }
}
pattern = typeof pattern === 'string'
? { from: pattern }
: { ...pattern }
flozero marked this conversation as resolved.
Show resolved Hide resolved

// `from` will be resolved based on `sourceDir`
pattern.from = resolve(context.sourceDir, pattern.from || '')
if (!existsSync(pattern.from)) return

// `to` will be resolved based on `outDir`
pattern.to = resolve(context.outDir, pattern.to || '')
})])

// ignore dotfiles and markdown by default
pattern.ignore = pattern.ignore || ['.*', '.*/**', '*.md']

return pattern
}).filter(p => p)])
}
})
}), 'flat')
3 changes: 2 additions & 1 deletion packages/@vuepress/plugin-public-files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"homepage": "https://github.com/vuejs/vuepress/packages/@vuepress/plugin-public-files#readme",
"dependencies": {
"@vuepress/shared-utils": "^1.0.0-alpha.44",
"copy-webpack-plugin": "^5.0.2"
"copy-webpack-plugin": "^5.0.2",
"vuepress-mergeable": "^1.0.1"
}
}
93 changes: 32 additions & 61 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ array-flatten@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2"

array-flatten@^2.1.0:
array-flatten@^2.1.0, array-flatten@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-2.1.2.tgz#24ef80a28c1a893617e2149b0c6d0d788293b099"

Expand Down Expand Up @@ -2297,25 +2297,7 @@ cac@^6.3.9:
version "6.4.2"
resolved "https://registry.yarnpkg.com/cac/-/cac-6.4.2.tgz#6b2a2ab12619b778b3acc19f97e5298761d9c3de"

cacache@^10.0.4:
version "10.0.4"
resolved "https://registry.yarnpkg.com/cacache/-/cacache-10.0.4.tgz#6452367999eff9d4188aefd9a14e9d7c6a263460"
dependencies:
bluebird "^3.5.1"
chownr "^1.0.1"
glob "^7.1.2"
graceful-fs "^4.1.11"
lru-cache "^4.1.1"
mississippi "^2.0.0"
mkdirp "^0.5.1"
move-concurrently "^1.0.1"
promise-inflight "^1.0.1"
rimraf "^2.6.2"
ssri "^5.2.4"
unique-filename "^1.1.0"
y18n "^4.0.0"

cacache@^11.0.1, cacache@^11.0.2, cacache@^11.3.2:
cacache@^11.0.1, cacache@^11.0.2, cacache@^11.3.1, cacache@^11.3.2:
version "11.3.2"
resolved "https://registry.yarnpkg.com/cacache/-/cacache-11.3.2.tgz#2d81e308e3d258ca38125b676b98b2ac9ce69bfa"
dependencies:
Expand Down Expand Up @@ -2496,7 +2478,7 @@ chokidar@^2.0.0, chokidar@^2.0.2, chokidar@^2.0.3:
optionalDependencies:
fsevents "^1.2.7"

chownr@^1.0.1, chownr@^1.1.1:
chownr@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.1.tgz#54726b8b8fff4df053c42187e801fb4412df1494"

Expand Down Expand Up @@ -3025,18 +3007,22 @@ copy-descriptor@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"

copy-webpack-plugin@^4.5.1:
version "4.6.0"
resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-4.6.0.tgz#e7f40dd8a68477d405dd1b7a854aae324b158bae"
copy-webpack-plugin@^5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-5.0.2.tgz#56186dfddbf9aa1b29c97fa4c796c1be98870da4"
integrity sha512-7nC7EynPrnBTtBwwbG1aTqrfNS1aTb9eEjSmQDqFtKAsJrR3uDb+pCDIFT2LzhW+SgGJxQcYzThrmXzzZ720uw==
dependencies:
cacache "^10.0.4"
find-cache-dir "^1.0.0"
cacache "^11.3.1"
find-cache-dir "^2.0.0"
glob-parent "^3.1.0"
globby "^7.1.1"
is-glob "^4.0.0"
loader-utils "^1.1.0"
minimatch "^3.0.4"
p-limit "^1.0.0"
normalize-path "^3.0.0"
p-limit "^2.1.0"
serialize-javascript "^1.4.0"
webpack-log "^2.0.0"

core-js@^2.4.0, core-js@^2.5.7, core-js@^2.6.5:
version "2.6.5"
Expand Down Expand Up @@ -3341,6 +3327,13 @@ decode-uri-component@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"

deconstruct-merge@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/deconstruct-merge/-/deconstruct-merge-1.1.0.tgz#ed9986ce729d9e67bdbc5780a771a021947ab3d3"
integrity sha512-o0RFi4YhLf+FJKQ2ly7iDePl9WtdY+RJIPd0wEDlMlK0wTxfywS9DxYQeei8N4qqHKoy8Idp4UXPtXFIVn0PrA==
dependencies:
array-flatten "^2.1.2"

dedent@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c"
Expand Down Expand Up @@ -4203,14 +4196,6 @@ finalhandler@1.1.1:
statuses "~1.4.0"
unpipe "~1.0.0"

find-cache-dir@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f"
dependencies:
commondir "^1.0.1"
make-dir "^1.0.0"
pkg-dir "^2.0.0"

find-cache-dir@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-2.0.0.tgz#4c1faed59f45184530fb9d7fa123a4d04a98472d"
Expand Down Expand Up @@ -6200,7 +6185,7 @@ lower-case@^1.1.1:
version "1.1.4"
resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac"

lru-cache@^4.0.1, lru-cache@^4.1.1, lru-cache@^4.1.2, lru-cache@^4.1.3:
lru-cache@^4.0.1, lru-cache@^4.1.2, lru-cache@^4.1.3:
version "4.1.5"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd"
dependencies:
Expand Down Expand Up @@ -6508,21 +6493,6 @@ minizlib@^1.1.1:
dependencies:
minipass "^2.2.1"

mississippi@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-2.0.0.tgz#3442a508fafc28500486feea99409676e4ee5a6f"
dependencies:
concat-stream "^1.5.0"
duplexify "^3.4.2"
end-of-stream "^1.1.0"
flush-write-stream "^1.0.0"
from2 "^2.1.0"
parallel-transform "^1.1.0"
pump "^2.0.1"
pumpify "^1.3.3"
stream-each "^1.1.0"
through2 "^2.0.0"

mississippi@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-3.0.0.tgz#ea0a3291f97e0b5e8776b363d5f0a12d94c67022"
Expand Down Expand Up @@ -7085,13 +7055,13 @@ p-is-promise@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-2.0.0.tgz#7554e3d572109a87e1f3f53f6a7d85d1b194f4c5"

p-limit@^1.0.0, p-limit@^1.1.0:
p-limit@^1.1.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8"
dependencies:
p-try "^1.0.0"

p-limit@^2.0.0:
p-limit@^2.0.0, p-limit@^2.1.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2"
dependencies:
Expand Down Expand Up @@ -7799,7 +7769,7 @@ public-encrypt@^4.0.0:
randombytes "^2.0.1"
safe-buffer "^5.1.2"

pump@^2.0.0, pump@^2.0.1:
pump@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909"
dependencies:
Expand Down Expand Up @@ -8731,12 +8701,6 @@ sshpk@^1.7.0:
safer-buffer "^2.0.2"
tweetnacl "~0.14.0"

ssri@^5.2.4:
version "5.3.0"
resolved "https://registry.yarnpkg.com/ssri/-/ssri-5.3.0.tgz#ba3872c9c6d33a0704a7d71ff045e5ec48999d06"
dependencies:
safe-buffer "^5.1.1"

ssri@^6.0.0, ssri@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8"
Expand Down Expand Up @@ -9321,7 +9285,7 @@ uniqs@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/uniqs/-/uniqs-2.0.0.tgz#ffede4b36b25290696e6e165d4a59edb998e6b02"

unique-filename@^1.1.0, unique-filename@^1.1.1:
unique-filename@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/unique-filename/-/unique-filename-1.1.1.tgz#1d69769369ada0583103a1e6ae87681b56573230"
dependencies:
Expand Down Expand Up @@ -9567,6 +9531,13 @@ vuepress-html-webpack-plugin@^3.2.0:
toposort "^1.0.0"
util.promisify "1.0.0"

vuepress-mergeable@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/vuepress-mergeable/-/vuepress-mergeable-1.0.1.tgz#0ed8c1953b88bc1943e7a84a2696860245f0b5b4"
integrity sha512-2rXnrs39o3W+AJi/9GTOcKvmSPcf6zny2Ru2xmB6f7W3hSPpXLI1AMSgOjRsbEGrimvxn/aviuCsQcj7U/wfmA==
dependencies:
deconstruct-merge "^1.1.0"

vuepress-plugin-flowchart@^1.4.2:
version "1.4.3"
resolved "https://registry.yarnpkg.com/vuepress-plugin-flowchart/-/vuepress-plugin-flowchart-1.4.3.tgz#1692807257c9ba02f764ced0caf930c627f65bdb"
Expand Down