Skip to content

Instantly share code, notes, and snippets.

@LinusBorg
Last active Mar 3, 2019
Embed
What would you like to do?
Adding a local plugin to a Vue CLI preset
// Local Plugin:
// https://cli.vuejs.org/guide/plugins-and-presets.html#project-local-plugin
// See also:
// https://cli.vuejs.org/dev-guide/plugin-dev.html#modifying-webpack-config
module.exports = api => {
const webpack = require('webpack')
api.configureWebpack({
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1
})
]
})
api.chainWebpack(config => {
config.optimization.delete('splitChunks')
})
}
module.exports = api => {
// https://cli.vuejs.org/dev-guide/plugin-dev.html#creating-new-templates
api.render('./chunksPlugin.js')
// We need to make cli aware of the local plugin by adding it to package.json
// https://cli.vuejs.org/dev-guide/plugin-dev.html#extending-package
api.extendPackage({
vuePlugins: {
service: ['chunksPlugin.js']
}
})
}
{
"useConfigFiles": true,
"router": true,
"plugins": {
"@vue/cli-plugin-babel": {},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment