From 81bcbbb92f36650e4319d0a07eb310b5ed568882 Mon Sep 17 00:00:00 2001 From: Patrick Neff Date: Mon, 6 May 2019 01:57:24 +0200 Subject: [PATCH] Split javascript files with webpack --- themes/neff/layouts/_default/baseof.html | 1 + themes/neff/layouts/catalog/single.html | 2 ++ themes/neff/webpack.common.js | 21 ++++++++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/themes/neff/layouts/_default/baseof.html b/themes/neff/layouts/_default/baseof.html index 65b5c1f..fa8c6d0 100755 --- a/themes/neff/layouts/_default/baseof.html +++ b/themes/neff/layouts/_default/baseof.html @@ -161,6 +161,7 @@ {{ partial "part/script.html" (dict "ctx" . "path" "js/common.bundle.js")}} + {{ partial "part/script.html" (dict "ctx" . "path" "js/app.bundle.js")}} {{- block "scripts" . -}}{{- end -}} diff --git a/themes/neff/layouts/catalog/single.html b/themes/neff/layouts/catalog/single.html index a5b289f..f22b9fb 100755 --- a/themes/neff/layouts/catalog/single.html +++ b/themes/neff/layouts/catalog/single.html @@ -34,5 +34,7 @@ {{- end -}} {{- define "scripts" -}} + {{ partial "part/script.html" (dict "ctx" . "path" "js/three.bundle.js")}} + {{ partial "part/script.html" (dict "ctx" . "path" "js/vue.bundle.js")}} {{ partial "part/script.html" (dict "ctx" . "path" "js/catalog.bundle.js")}} {{- end -}} diff --git a/themes/neff/webpack.common.js b/themes/neff/webpack.common.js index 647066e..6169dcc 100644 --- a/themes/neff/webpack.common.js +++ b/themes/neff/webpack.common.js @@ -6,7 +6,7 @@ const path = require("path") module.exports = { entry: { - common: ["./src/js/main.js"], + app: ["./src/js/main.js"], images: ["./src/js/images.js"], catalog: ["./src/js/catalog.js"], style: ["./src/scss/main.scss"], @@ -20,6 +20,25 @@ module.exports = { }, optimization: { //usedExports: true, + splitChunks: { + cacheGroups: { + common: { + name: 'common', + chunks: 'initial', + minChunks: 2 + }, + vue: { + test: /[\\/]node_modules[\\/](vue)[\\/]/, + name: 'vue', + chunks: 'all', + }, + three: { + test: /[\\/]node_modules[\\/](three)[\\/]/, + name: 'three', + chunks: 'all', + }, + } + }, }, module: { rules: [