Skip to content

refactor(build): consolidate build options - #4105

Merged
filipesilva merged 7 commits into
angular:masterfrom
filipesilva:refactor-build-options
Jan 24, 2017
Merged

refactor(build): consolidate build options#4105
filipesilva merged 7 commits into
angular:masterfrom
filipesilva:refactor-build-options

Conversation

@filipesilva

@filipesilvafilipesilva commented Jan 19, 2017

Copy link
Copy Markdown
Contributor

Fix#4138

BREAKING CHANGE:

  • --extractCss defaults to false on all --dev (ng build with no flags uses --dev)
  • --aot defaults to true in --prod
  • the alias for --output-path is now -op instead of -o

@filipesilva
filipesilvaforce-pushed the refactor-build-options branch 2 times, most recently from e657f2c to c93ffcaCompareJanuary 19, 2017 00:59
@hansl

Copy link
Copy Markdown
Contributor

Could you move XXX.run.ts to a separate directory? Seems like ng help still shows those.

@filipesilva

Copy link
Copy Markdown
ContributorAuthor

@hansl I'll do that in a followup PR. There's a few followups to this one that I want to do, but trying to keep the scope of each down.

const project = this.cliProject;

const outputDir = runTaskOptions.outputPath || CliConfig.fromProject().config.apps[0].outDir;
const deployUrl = runTaskOptions.deployUrl ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seemed you remove the functionality of using deployUrl via the config file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry.
I just find it in addAppConfigDefaults

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I transferred it over to packages/angular-cli/models/webpack-config.ts, in the addAppConfigDefaults function.

To make sure your functionality in #4090 also is in, I force a value for deployUrl in packages/angular-cli/tasks/serve-webpack.ts via serveDefaults.

This way in for ng serve, the default for --deploy-url is '' instead of undefined and thus the default in angular-cli.json is not used.

I believe this was your intention.

@changLiuUNSWchangLiuUNSWJan 19, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is my intention.
Did you test the css url path whether it points to the correct place with --extractCss=false and --deploy-url?
I suspect it may have same issue like:
#4035

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored the tests around a bit and that test is in tests/e2e/tests/build/styles/extract-css.ts, the last test. Can you double check if that's right?

@filipesilva
filipesilvaforce-pushed the refactor-build-options branch from c93ffca to dedf216CompareJanuary 19, 2017 13:34
<script type="text/javascript" src="main.bundle.js"></script>
`))
// verify --deploy-url isn't applied to extracted urls
.then(() => ng('build', '--extract-css', '--deploy-url=client/'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test with --deploy-url=client/ and --extract-css=false?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should be the output?

@changLiuUNSWchangLiuUNSWJan 19, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if --extract-css=false, styles will be inserted as <style> tags into the index.html. Normally the index.html will not be under the same path with deploy-url , so the CSS asset url should point to the full path [deployUrl]/[assetName]. In this case, the correct result should be client/more.svg
However, I cannot make sure now. I will have a check tomorrow.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filipesilva
Sorry for keep editing the comment....
Not sure what the expect result right now. Will update after verifying later

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok let me know when you figure it out. Worst case scenario the new test goes into a new PR.

I believe there should be a way --deployUrl/ also work with ng serve (it's mentioned here) but haven't looked into it much as it's out of scope of this PR.

@changLiuUNSWchangLiuUNSWJan 20, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed.
Should be the full path [deployUrl]/[assetName]. In this case, it is client/more.svg.
Do not how you test it, because the CSS is inserted by JavaScript when page is loaded

@filipesilva
filipesilvaforce-pushed the refactor-build-options branch 2 times, most recently from a6896a0 to 90c9dd1CompareJanuary 19, 2017 22:39
@filipesilva

filipesilva commented Jan 20, 2017

Copy link
Copy Markdown
ContributorAuthor

@changLiuUNSW added this test to address #4105 (comment)

 // verify --deploy-url is applied to non-extracted css urls
.then(() => ng('build', '--deploy-url=deployUrl/', '--extract-css=false'))
.then(() => expectFileToMatch('dist/styles.bundle.css', '__webpack_require__.p \+ \"more.svg\"'));

Edit: updated the test, turns out the import looks like this instead: __webpack_require__.p + "more.svg";

@filipesilva
filipesilvaforce-pushed the refactor-build-options branch from 8746401 to dab74e8CompareJanuary 20, 2017 22:28
@changLiuUNSW

Copy link
Copy Markdown
Contributor

LGTM

@filipesilva
filipesilvaforce-pushed the refactor-build-options branch from d339bb1 to dfa54daCompareJanuary 22, 2017 20:17
@Brocco

Copy link
Copy Markdown
Contributor

Please update documentation to account for changes in options. For example output path's alias has gone from -o to -op

@filipesilva
filipesilvaforce-pushed the refactor-build-options branch from bbc9e53 to 62f8f98CompareJanuary 24, 2017 17:16
@filipesilva
filipesilva merged commit e15433e into angular:masterJan 24, 2017
@filipesilva
filipesilva deleted the refactor-build-options branch January 24, 2017 17:51
MRHarrison pushed a commit to MRHarrison/angular-cli that referenced this pull request Feb 9, 2017
Fixangular#4138
BREAKING CHANGE:
- `--extractCss` defaults to `false` on all `--dev` (`ng build` with no flags uses `--dev`)
- `--aot` defaults to true in `--prod`
- the alias for `--output-path` is now `-op` instead of `-o`
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-botangular-automatic-lock-botBot locked and limited conversation to collaborators Sep 11, 2019
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default AOT to true in prod

5 participants

@filipesilva@hansl@changLiuUNSW@Brocco@googlebot