@@ -3,8 +3,13 @@ import * as path from 'path';
33import { GlobCopyWebpackPlugin } from '../../plugins/glob-copy-webpack-plugin' ;
44import { packageChunkSort } from '../../utilities/package-chunk-sort' ;
55import { BaseHrefWebpackPlugin } from '../../lib/base-href-webpack' ;
6- import { extraEntryParser , lazyChunksFilter , getOutputHashFormat } from './utils' ;
76import { WebpackConfigOptions } from '../webpack-config' ;
7+ import {
8+ extraEntryParser ,
9+ lazyChunksFilter ,
10+ getOutputHashFormat ,
11+ getCommonOutputPath ,
12+ } from './utils' ;
813
914const autoprefixer = require ( 'autoprefixer' ) ;
1015const ProgressPlugin = require ( 'webpack/lib/ProgressPlugin' ) ;
@@ -50,6 +55,8 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
5055 // determine hashing format
5156 const hashFormat = getOutputHashFormat ( buildOptions . outputHashing ) ;
5257
58+ const commonOutputPath = getCommonOutputPath ( appConfig , hashFormat ) ;
59+
5360 // process global scripts
5461 if ( appConfig . scripts . length > 0 ) {
5562 const globalScripts = extraEntryParser ( appConfig . scripts , appRoot , 'scripts' ) ;
@@ -96,18 +103,32 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
96103 output : {
97104 path : path . resolve ( projectRoot , buildOptions . outputPath ) ,
98105 publicPath : buildOptions . deployUrl ,
99- filename : `[name]${ hashFormat . chunk } .bundle.js` ,
100- chunkFilename : `[id]${ hashFormat . chunk } .chunk.js`
106+ filename : `${ appConfig . bundlesOutDir } / [name]${ hashFormat . chunk } .bundle.js` ,
107+ chunkFilename : `${ appConfig . bundlesOutDir } / [id]${ hashFormat . chunk } .chunk.js`
101108 } ,
102109 module : {
103110 rules : [
104- { enforce : 'pre' , test : / \. j s $ / , loader : 'source-map-loader' , exclude : [ nodeModules ] } ,
105- { test : / \. j s o n $ / , loader : 'json-loader' } ,
106- { test : / \. h t m l $ / , loader : 'raw-loader' } ,
107- { test : / \. ( e o t | s v g ) $ / , loader : `file-loader?name=[name]${ hashFormat . file } .[ext]` } ,
111+ {
112+ enforce : 'pre' ,
113+ test : / \. j s $ / ,
114+ loader : `source-map-loader?name=${ commonOutputPath } ` ,
115+ exclude : [ nodeModules ]
116+ } ,
117+ {
118+ test : / \. j s o n $ / ,
119+ loader : `json-loader?name=${ commonOutputPath } `
120+ } ,
121+ {
122+ test : / \. h t m l $ / ,
123+ loader : `raw-loader?name=${ commonOutputPath } `
124+ } ,
125+ {
126+ test : / \. ( e o t | s v g ) $ / ,
127+ loader : `file-loader?name=${ commonOutputPath } `
128+ } ,
108129 {
109130 test : / \. ( j p g | p n g | g i f | o t f | t t f | w o f f | w o f f 2 | c u r | a n i ) $ / ,
110- loader : `url-loader?name=[name] ${ hashFormat . file } .[ext] &limit=10000`
131+ loader : `url-loader?name=${ commonOutputPath } &limit=10000`
111132 }
112133 ] . concat ( extraRules )
113134 } ,
0 commit comments