1.0.0 • Published 4 years ago
jsonpscriptsrc-webpack-plugin v1.0.0
jsonpscriptsrc-webpack-plugin
Note: only support webpack 4.x
Override webpack runtime jsonpscriptsrc function.
install
yarn add -dev jsonpscriptsrc-webpack-pluginusage
webpack.config.js
const {JsonpScriptSrcPlugin} = require('jsonpscriptsrc-webpack-plugin')
module.exports = {
...
plugins:[
new JsonpScriptSrcPlugin({
customJsonpSrc(chunkId, chunkMaps, original) {
// code
// return your runtime src here
}
})
]
}options
| name | type | Default |
|---|---|---|
| customJsonpSrc | {Function} | - |
| compilerOptions | {Object} | {jsc:{target:'es5'}} |
customJsonpSrc
| name | type | description |
|---|---|---|
| chunkId | {String} | The parameters of the original jsonpScriptsrc function . |
| chunkMaps | {Object} | An object contains all the async chunks generated by webpack. |
| original | {String} | The return value of the original jsonpScriptsrc function. |
Only supports the first way of writing options.customJsonpSrc
// #1
{
customJsonpSrc(chunkId, chunkMaps, original) {}
}
// #2
{
customJsonpSrc: (chunkId, chunkMaps, original) => {}
}
// #3
{
customJsonpSrc: function(chunkId, chunkMaps, original) {}
}compilerOptions
This plugin use swc transform customJsonpSrc function body content to es5. compilerOptions is the args of transform function.
1.0.0
4 years ago