Skip to content

Commit 1a28183

Browse files
author
Pooya Parsa
committed
perf: use webpack 4 cacheGroup for framework7
1 parent 6cc0eec commit 1a28183

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

Diff for: lib/module.js

+24-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ module.exports = function nuxt7 (_options) {
2424
// Disable postcss for less transformations
2525
this.options.build.postcss = false
2626

27+
// Extend webpack config
28+
this.extendBuild(config => extendConfig(config, options))
29+
2730
// Global theme color
2831
if (options.themeColor) {
2932
options.build.ios.themeColor = options.themeColor
@@ -40,6 +43,18 @@ module.exports = function nuxt7 (_options) {
4043
this.addVendor('dom7')
4144
this.addVendor('template7')
4245

46+
// Webpack 4 cacheGroup
47+
if (this.options.build.optimization) {
48+
const { cacheGroups } = this.options.build.optimization.splitChunks
49+
50+
cacheGroups.framework7 = {
51+
test: /node_modules[\\/](framework7|framework7-vue|dom7|template7|ssr-window|path-to-regexp)[\\/]/,
52+
chunks: 'all',
53+
priority: 10,
54+
name: 'framework7'
55+
}
56+
}
57+
4358
// Remove custom keys for framework7 plugin
4459
options.plugin = omit(options, extraKeys)
4560

@@ -77,9 +92,15 @@ module.exports = function nuxt7 (_options) {
7792
return Promise.resolve()
7893
}
7994

80-
// ----------------------------------------------------------
81-
// Add templates
82-
// ----------------------------------------------------------
95+
function extendConfig (config, options) {
96+
// Increase performance check limits to 2M (non-gzipped)
97+
const MAX_SIZE = 2 * 1024 * 1024
98+
Object.assign(config.performance, {
99+
maxEntrypointSize: MAX_SIZE,
100+
maxAssetSize: MAX_SIZE
101+
})
102+
}
103+
83104
function addTemplates (options) {
84105
// Framework7 plugin
85106
this.addPlugin({

0 commit comments

Comments
 (0)