Skip to content

Commit

Permalink
add (semi) polyfilled builds
Browse files Browse the repository at this point in the history
  • Loading branch information
redxtech committed Nov 3, 2020
1 parent 1ba9cd8 commit 570b1f3
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 564 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@vue/cli-plugin-babel": "^4.5.8",
"@vue/cli-plugin-eslint": "^4.5.8",
"@vue/cli-service": "^4.5.8",
"@vue/compiler-sfc": "^3.0.2",
"@vue/eslint-config-prettier": "^6.0.0",
"babel-eslint": "^10.1.0",
"core-js": "^3.6.5",
Expand All @@ -54,7 +55,7 @@
"rollup": "^2.33.0",
"rollup-plugin-css-only": "^2.1.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-vue": "^5.1.9",
"rollup-plugin-vue": "^6.0.0-beta.10",
"vue-template-compiler": "^2.6.12"
},
"keywords": [
Expand Down
33 changes: 33 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,38 @@ if (!argv.format || argv.format === 'iife') {
buildFormats.push(unpkgConfig)
}

const copy = obj => {
if (!obj) {
return obj
}

let v
let copied = Array.isArray(obj) ? [] : {}
for (const k in obj) {
v = obj[k]
copied[k] = typeof v === 'object' ? copy(v) : v
}

return copied
}

if (!argv.format) {
buildFormats.forEach(format => {
const polyfilled = copy(format)
polyfilled.output.file = format.output.file.replace(
/vue-plyr\./,
'vue-plyr.polyfilled.'
)
polyfilled.plugins.unshift(
replace({
"import Plyr from 'plyr'":
"import Plyr from 'plyr/dist/plyr.polyfilled'",
delimiters: ['', '']
})
)
buildFormats.push(polyfilled)
})
}

// Export config
export default buildFormats
Loading

0 comments on commit 570b1f3

Please sign in to comment.