Skip to content
Snippets Groups Projects
Commit 6d1548f8 authored by Winnie Hellmann's avatar Winnie Hellmann
Browse files

Fix Webpack config for ConcatenatedModule

parent b1e1990e
No related branches found
No related tags found
No related merge requests found
'use strict';
 
var crypto = require('crypto');
var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
Loading
Loading
@@ -179,15 +180,34 @@ var config = {
if (chunk.name) {
return chunk.name;
}
return chunk.mapModules((m) => {
const moduleNames = [];
function collectModuleNames(m) {
// handle ConcatenatedModule which does not have resource nor context set
if (m.modules) {
m.modules.forEach(collectModuleNames);
return;
}
const pagesBase = path.join(ROOT_PATH, 'app/assets/javascripts/pages');
if (m.resource.indexOf(pagesBase) === 0) {
return path.relative(pagesBase, m.resource)
moduleNames.push(path.relative(pagesBase, m.resource)
.replace(/\/index\.[a-z]+$/, '')
.replace(/\//g, '__');
.replace(/\//g, '__'));
} else {
moduleNames.push(path.relative(m.context, m.resource));
}
return path.relative(m.context, m.resource);
}).join('_');
}
chunk.forEachModule(collectModuleNames);
const hash = crypto.createHash('sha256')
.update(moduleNames.join('_'))
.digest('hex');
return `${moduleNames[0]}-${hash.substr(0, 6)}`;
}),
 
// create cacheable common library bundle for all vue chunks
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment