Skip to content

Instantly share code, notes, and snippets.

@LinusBorg
Last active March 3, 2019 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LinusBorg/c6fb4235704fde98fe182a12dcce3ba0 to your computer and use it in GitHub Desktop.
Save LinusBorg/c6fb4235704fde98fe182a12dcce3ba0 to your computer and use it in GitHub Desktop.
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