-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
angular-cli 6 (with webpack 4) compatibility #3491
Changes from 2 commits
96b5668
575ad6a
b74b4f8
06e6e05
a36fc9f
c8ace6c
48044eb
68c4b61
a41e08a
a25b4cd
45a29df
d4ea7e4
1689458
28a06ac
a32e314
7bbaf8f
9b13bfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { logger } from '@storybook/node-logger'; | |
|
||
function isAngularCliInstalled() { | ||
try { | ||
require.resolve('@angular/cli'); | ||
require.resolve('@angular-devkit/build-angular'); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
|
@@ -21,12 +21,19 @@ export function getAngularCliWebpackConfigOptions(dirToSearch, appIndex = 0) { | |
throw new Error('.angular-cli.json must have apps entry.'); | ||
} | ||
const appConfig = cliConfig.apps[appIndex]; | ||
const { root, styles, scripts } = appConfig; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should read the build options from const angularJson = JSON.parse(fs.readFileSync(path.resolve(dirToSearch, 'angular.json'), 'utf8'))
const project = angularJson['projects'][angularJson['defaultProject']];
const cliWebpackConfigOptions = {
buildOptions: project.architect.build.options,
root: project.root,
projectRoot: dirToSearch,
supportES2015: false,
tsConfig: {
options: { },
fileNames: [],
errors: [],
},
tsConfigPath: path.resolve(dirToSearch, 'src/tsconfig.app.json'),
}; I've created the sample repo to extract webpack config object using |
||
|
||
const cliWebpackConfigOptions = { | ||
root, | ||
projectRoot: dirToSearch, | ||
appConfig, | ||
buildOptions: { | ||
outputPath: 'outputPath', // It's dummy value to avoid to Angular CLI's error | ||
scripts, | ||
styles, | ||
}, | ||
tsConfig: { | ||
options: {}, | ||
}, | ||
supportES2015: false, | ||
}; | ||
|
@@ -43,7 +50,7 @@ export function applyAngularCliWebpackConfig(baseConfig, cliWebpackConfigOptions | |
} | ||
|
||
// eslint-disable-next-line global-require, import/no-extraneous-dependencies | ||
const ngcliConfigFactory = require('@angular/cli/models/webpack-configs'); | ||
const ngcliConfigFactory = require('@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs'); | ||
|
||
let cliCommonConfig; | ||
let cliStyleConfig; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,20 +13,22 @@ | |
"test": "ng test" | ||
}, | ||
"dependencies": { | ||
"@angular/common": "^5.2.10", | ||
"@angular/compiler": "^5.2.10", | ||
"@angular/core": "^5.2.10", | ||
"@angular/forms": "^5.2.10", | ||
"@angular/platform-browser": "^5.2.10", | ||
"@angular/platform-browser-dynamic": "^5.2.10", | ||
"@ngrx/store": "^5.2.0", | ||
"@angular/common": "^6.0.0-rc.5", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned above, new angular/cli v6 needs not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stable 6 version is out now, please upgrade There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I am on it |
||
"@angular/compiler": "^6.0.0-rc.5", | ||
"@angular/core": "^6.0.0-rc.5", | ||
"@angular/forms": "^6.0.0-rc.5", | ||
"@angular/platform-browser": "^6.0.0-rc.5", | ||
"@angular/platform-browser-dynamic": "^6.0.0-rc.5", | ||
"@ngrx/store": "^6.0.0-beta.1", | ||
"core-js": "^2.5.5", | ||
"rxjs": "^5.5.10", | ||
"rxjs": "^6.0.0", | ||
"rxjs-compat": "^6.0.0", | ||
"zone.js": "^0.8.26" | ||
}, | ||
"devDependencies": { | ||
"@angular/cli": "1.7.4", | ||
"@angular/compiler-cli": "^5.2.10", | ||
"@angular-devkit/build-angular": "^0.5.8", | ||
"@angular/cli": "^6.0.0-rc.6", | ||
"@angular/compiler-cli": "^6.0.0-rc.5", | ||
"@storybook/addon-actions": "4.0.0-alpha.3", | ||
"@storybook/addon-knobs": "4.0.0-alpha.3", | ||
"@storybook/addon-links": "4.0.0-alpha.3", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
@angular/cli
module is no longer needed, so I prefer such asisBuildAngularInstalled
.