Split javascript files with webpack

This commit is contained in:
Patrick Neff 2019-05-06 01:57:24 +02:00
parent b8df293a52
commit 81bcbbb92f
3 changed files with 23 additions and 1 deletions

View File

@ -161,6 +161,7 @@
</script> </script>
{{ partial "part/script.html" (dict "ctx" . "path" "js/common.bundle.js")}} {{ 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 -}} {{- block "scripts" . -}}{{- end -}}
</body> </body>
</html> </html>

View File

@ -34,5 +34,7 @@
{{- end -}} {{- end -}}
{{- define "scripts" -}} {{- 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")}} {{ partial "part/script.html" (dict "ctx" . "path" "js/catalog.bundle.js")}}
{{- end -}} {{- end -}}

View File

@ -6,7 +6,7 @@ const path = require("path")
module.exports = { module.exports = {
entry: { entry: {
common: ["./src/js/main.js"], app: ["./src/js/main.js"],
images: ["./src/js/images.js"], images: ["./src/js/images.js"],
catalog: ["./src/js/catalog.js"], catalog: ["./src/js/catalog.js"],
style: ["./src/scss/main.scss"], style: ["./src/scss/main.scss"],
@ -20,6 +20,25 @@ module.exports = {
}, },
optimization: { optimization: {
//usedExports: true, //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: { module: {
rules: [ rules: [