-
-
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
Conversation
@@ -4,7 +4,7 @@ import { logger } from '@storybook/node-logger'; | |||
|
|||
function isAngularCliInstalled() { |
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 as isBuildAngularInstalled
.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
We should read the build options from angular.json
(not .angular-cli.json
). And the structures of them are not compatible.
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 @angular-devkit/build-angular
https://github.com/Quramy/how-to-extract-webpack-conf-from-angular-cli
examples/angular-cli/package.json
Outdated
"@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 comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned above, new angular/cli v6 needs not .angular-cli.json
but angular.json
. I think it's better to re-generate the example project with ng new angular-cli
.
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.
Stable 6 version is out now, please upgrade
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.
Yeah, I am on it
…egration # Conflicts: # examples/angular-cli/package.json # yarn.lock
Codecov Report
@@ Coverage Diff @@
## master #3491 +/- ##
==========================================
- Coverage 41.45% 41.42% -0.04%
==========================================
Files 458 459 +1
Lines 5075 5077 +2
Branches 853 855 +2
==========================================
- Hits 2104 2103 -1
Misses 2464 2464
- Partials 507 510 +3
Continue to review full report at Codecov.
|
@Quramy, I have a strange thing with "assets" prop. I was needed to override it like this: buildOptions: {
...project.architect.build.options,
assets: [],
}, Otherwise, I am getting an error from this code: which is strange because assets were generated by angular-cli and they are: "assets": [
"src/favicon.ico",
"src/assets"
] |
…egration # Conflicts: # examples/angular-cli/package.json # yarn.lock
@klimentru1986, after your angular PRs, I assume you can help here =) |
@igor-dv , i find example in https://github.com/angular/devkit/blob/master/packages/angular_devkit/build_angular/src/utils/normalize-asset-patterns.ts It`s just a bit ugly, but it is prototype. I think the best way is to rewrite this part of angular-storybook to typescript and use angular-devkit default methods with observable. )) |
is this going to get fixed? |
…egration # Conflicts: # examples/angular-cli/package.json # yarn.lock
@@ -0,0 +1,55 @@ | |||
import fs from 'fs'; | |||
import { basename, dirname, normalize, relative, resolve } from '@angular-devkit/core'; |
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.
If someone doesn't use angular-cli, will this dep still appear? I assume that it won't, that's why we added the isBuildAngularInstalled
func
What's the status of this @igor-dv ? |
…egration # Conflicts: # app/angular/src/server/config/webpack.config.js # examples/angular-cli/package.json # package.json # yarn.lock
Something bad happens with the static build after the merge from master 🤔 Looks related to webpack |
@Hypnosphi, do we have any WIP PR with upgrading webpack to 4.10.2 ? Looks like it solves a static build problem here |
…egration # Conflicts: # examples/marko-cli/package.json # yarn.lock
} | ||
|
||
return assetPatterns.map(assetPattern => { | ||
const assetPath = normalize(assetPattern); |
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.
Hi @igor-dv sorry to nudge you like this. I'm getting a an error here.
At this point my asset pattern looks like this:
{ glob: '**/*',
input: 'apps/viewer/src/assets',
output: '/assets' }
which throws the following error:
TypeError: path.match is not a function
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.
Thanks, will take a look
Issue: #3399
What I did
CC. @Quramy @avol-io @bengry