mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-22 15:02:11 +08:00
fix(@angular-devkit/build-angular): configure webpack target in common configuration
Previously, `target` was unset for `test` which caused the target to be set incorrectly. Closes #21239
This commit is contained in:
parent
6a2b11906e
commit
070a133647
@ -81,10 +81,6 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati
|
|||||||
resolve: {
|
resolve: {
|
||||||
mainFields: ['es2015', 'browser', 'module', 'main'],
|
mainFields: ['es2015', 'browser', 'module', 'main'],
|
||||||
},
|
},
|
||||||
target:
|
|
||||||
wco.tsConfig.options.target === ScriptTarget.ES5 || buildBrowserFeatures.isEs5SupportNeeded()
|
|
||||||
? ['web', 'es5']
|
|
||||||
: 'web',
|
|
||||||
output: {
|
output: {
|
||||||
crossOriginLoading,
|
crossOriginLoading,
|
||||||
trustedTypes: 'angular#bundler',
|
trustedTypes: 'angular#bundler',
|
||||||
|
@ -40,7 +40,6 @@ import {
|
|||||||
maxWorkers,
|
maxWorkers,
|
||||||
persistentBuildCacheEnabled,
|
persistentBuildCacheEnabled,
|
||||||
profilingEnabled,
|
profilingEnabled,
|
||||||
shouldBeautify,
|
|
||||||
} from '../../utils/environment-options';
|
} from '../../utils/environment-options';
|
||||||
import { findAllNodeModules } from '../../utils/find-up';
|
import { findAllNodeModules } from '../../utils/find-up';
|
||||||
import { Spinner } from '../../utils/spinner';
|
import { Spinner } from '../../utils/spinner';
|
||||||
@ -358,12 +357,19 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
|
|||||||
return {
|
return {
|
||||||
mode: scriptsOptimization || stylesOptimization.minify ? 'production' : 'development',
|
mode: scriptsOptimization || stylesOptimization.minify ? 'production' : 'development',
|
||||||
devtool: false,
|
devtool: false,
|
||||||
|
target: [
|
||||||
|
platform === 'server' ? 'node' : 'web',
|
||||||
|
tsConfig.options.target === ScriptTarget.ES5 ||
|
||||||
|
(platform !== 'server' && buildBrowserFeatures.isEs5SupportNeeded())
|
||||||
|
? 'es5'
|
||||||
|
: 'es2015',
|
||||||
|
],
|
||||||
profile: buildOptions.statsJson,
|
profile: buildOptions.statsJson,
|
||||||
resolve: {
|
resolve: {
|
||||||
roots: [projectRoot],
|
roots: [projectRoot],
|
||||||
extensions: ['.ts', '.tsx', '.mjs', '.js'],
|
extensions: ['.ts', '.tsx', '.mjs', '.js'],
|
||||||
symlinks: !buildOptions.preserveSymlinks,
|
symlinks: !buildOptions.preserveSymlinks,
|
||||||
modules: [wco.tsConfig.options.baseUrl || projectRoot, 'node_modules'],
|
modules: [tsConfig.options.baseUrl || projectRoot, 'node_modules'],
|
||||||
},
|
},
|
||||||
resolveLoader: {
|
resolveLoader: {
|
||||||
symlinks: !buildOptions.preserveSymlinks,
|
symlinks: !buildOptions.preserveSymlinks,
|
||||||
|
@ -35,7 +35,6 @@ export function getServerConfig(wco: WebpackConfigOptions): Configuration {
|
|||||||
resolve: {
|
resolve: {
|
||||||
mainFields: ['es2015', 'main', 'module'],
|
mainFields: ['es2015', 'main', 'module'],
|
||||||
},
|
},
|
||||||
target: 'node',
|
|
||||||
output: {
|
output: {
|
||||||
libraryTarget: 'commonjs',
|
libraryTarget: 'commonjs',
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user