Skip to content
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

refactor(build): consolidate build options #4105

Merged
merged 7 commits into from
Jan 24, 2017

Conversation

filipesilva
Copy link
Contributor

@filipesilva filipesilva commented Jan 19, 2017

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 filipesilva force-pushed the refactor-build-options branch 2 times, most recently from e657f2c to c93ffca Compare January 19, 2017 00:59
@hansl
Copy link
Contributor

hansl commented Jan 19, 2017

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

@filipesilva
Copy link
Contributor Author

@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
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
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
Contributor Author

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.

Copy link
Contributor

@changLiuUNSW changLiuUNSW Jan 19, 2017

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
Contributor Author

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 filipesilva force-pushed the refactor-build-options branch from c93ffca to dedf216 Compare January 19, 2017 13:34
<script type="text/javascript" src="common-entry.bundle.js"></script>
<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
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
Contributor Author

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?

Copy link
Contributor

@changLiuUNSW changLiuUNSW Jan 19, 2017

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
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
Contributor Author

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.

Copy link
Contributor

@changLiuUNSW changLiuUNSW Jan 20, 2017

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 filipesilva force-pushed the refactor-build-options branch 2 times, most recently from a6896a0 to 90c9dd1 Compare January 19, 2017 22:39
@filipesilva
Copy link
Contributor Author

filipesilva commented Jan 20, 2017

@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 filipesilva force-pushed the refactor-build-options branch from 8746401 to dab74e8 Compare January 20, 2017 22:28
@changLiuUNSW
Copy link
Contributor

LGTM

@filipesilva filipesilva force-pushed the refactor-build-options branch from d339bb1 to dfa54da Compare January 22, 2017 20:17
@Brocco
Copy link
Contributor

Brocco commented Jan 24, 2017

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

@filipesilva filipesilva force-pushed the refactor-build-options branch from bbc9e53 to 62f8f98 Compare January 24, 2017 17:16
@filipesilva filipesilva merged commit e15433e into angular:master Jan 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
Fix angular#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

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-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to 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