Skip to content

Commit

Permalink
Use rootModule when module is concatenated
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed Dec 1, 2021
1 parent 3b564d4 commit c4251a2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ module.exports = {
publicPath: '/dist/',
filename: (chunkData) => {
// Get relative path of the src folder
const srcPath = chunkData.chunk.entryModule.context
let srcPath = chunkData.chunk.entryModule.context
if (srcPath === null) {
srcPath = chunkData.chunk.entryModule.rootModule.context
}
const relativePath = path.relative(__dirname, srcPath)

// If this is a core source, output in core dist folder
if (relativePath.indexOf('core/src') > -1) {
return path.join('core/js/dist/', '[name].js?v=[contenthash]')
}
// Get out of the shared dist folder and output inside apps js folder
return path.join(relativePath, '..', 'js') + '/[name].js?v=[contenthash]'
return path.join(relativePath, '..', 'js') + '/dist/[name].js?v=[contenthash]'
},
chunkFilename: 'dist/[name]-[id].js?v=[contenthash]',
},
Expand Down

0 comments on commit c4251a2

Please sign in to comment.