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

feat(build): add support for assets array #2570

Merged
merged 2 commits into from
Oct 8, 2016

Conversation

filipesilva
Copy link
Contributor

@filipesilva filipesilva commented Oct 7, 2016

This PR enables the assets entry in angular-cli.json to be an array of globs:

      "assets": [
        "assets",
        "favicon.ico",
        ".htaccess",
        "cat-picks/**/*"
      ],

Previous behavior (`"assets": "assets") will still work, but might be deprecated/removed in future versions.

Close #1942
Close #2405

@filipesilva filipesilva force-pushed the add-assets-array branch 6 times, most recently from 4d27131 to e48306e Compare October 7, 2016 17:57
@filipesilva filipesilva merged commit de3c275 into angular:master Oct 8, 2016
@filipesilva filipesilva deleted the add-assets-array branch October 8, 2016 13:53
@NgxDev
Copy link

NgxDev commented Oct 9, 2016

If we have src/public/assets/ and src/public/a-bunch-of-files.ext
Will this:

"assets": [
        "public/assets/**/*",
        "public/*"
],

copy contents of src/public/assets folder to dist root?
And also copy any file that's directly in /src/public straight to dist root?

I'm asking because, right now (beta-17) if I do this:

"assets": "public/assets"

It doesn't create an assets folder in dist, but instead it starts with public... so I get dist/public/assets instead of dist/assets. And "assets": "public/assets/*" doesn't work (I suppose it's not even meant to, in beta-17).

I'm creating an additional folder (public) because, if we have have a bunch of folders and files to get copied straight to dist root, we wouldn't want to pollute the src folder too much (with a bunch of folders and files, which are simply static assets).

@filipesilva
Copy link
Contributor Author

@MrCroft this will always mirror the structure you have. For if you have src/public/assets/ and use public/assets in the config, you will get dist/public/assets/.

@NgxDev
Copy link

NgxDev commented Oct 10, 2016

I understand.

Unfortunately, if we have 2 different folders and 5 files which each need to be in dist root, we have no choice but to pollute the src folder with those 2 folders and 5 files... I think.
Now, granted... having multiple folders which each need to be in dist root is probably quite rare, but having one folder and multiple files that each needs to be in dist root - that's a more common scenario.

Would make more sense that "assets" copies over keeping the structure (so dist/assets/...), and "assets/**/*" would recreate the structure starting after assets/ (not including assets), thus getting dist/what-ever-is-in-assets.

Otherwise, this also means that there is no difference between let's say cat-picks and cat-picks/**/*.

Thank you for the clarification.

@filipesilva
Copy link
Contributor Author

filipesilva commented Oct 10, 2016

Correct, cat-picks and cat-picks/**/* are exactly the same under this PR. I specialcased dir globs to add /**/* in front even.

We felt it was better this way have a 30m discussion in the team where everyone had different expectations of how this would work. So to make it as simple as possible, path is always kept.

@SolutiaConsulting
Copy link

I upgraded angular cli to 1.0.0-beta.17. I added the following to angular-cli.json:

{ ... "assets": [ "./src/favicon.ico", "./src/Web.config" ] ... }

favicon.ico and Web.config are not getting copied to dist folder. I'm running this command:

ng build --env=dev -o dist/dev

How do I get favicon.ico and Web.config copied from src folder to dist environment root folder?

@NgxDev
Copy link

NgxDev commented Oct 11, 2016

@SolutiaConsulting I don't think this feature is in beta 17. It seems that Beta 17 was released before this merge. So, it will probably be in the next release.

JJayet pushed a commit to JJayet/angular-cli that referenced this pull request Oct 14, 2016
@filipesilva
Copy link
Contributor Author

Correct, this feature will be part of the next release, but is not in beta.17.

@fabianderijk
Copy link

Is there any idea on when the next release is due? I've ran into this problem as well. I've added a .htaccess file to the app folder, and that also needs to bee in my dist folder. But for now it isn't. Because we use Jenkins to build the app, and it overwrites the complete old folder, we need the .htaccess from the build. Or is there an other way around this?

@Splaktar
Copy link
Member

@fabianderijk beta.18 is out today!

@cmermingas
Copy link

@filipesilva, @Splaktar - This should be added to the readme, specifically here:

https://github.com/angular/angular-cli#project-assets

It's an easy task... OK to create a pull request and add it myself or should I open an issue?

@sime
Copy link
Contributor

sime commented Oct 26, 2016

@cmermingas I have started a quick README update in #2905

wangbus added a commit to cypherpunkengineering/cypherpunk-browser-extension that referenced this pull request Oct 29, 2016
- angular cli's lack of ability to do this at the moment is fixed in
  future builds: angular/angular-cli#2570
texel pushed a commit to splice/angular-cli that referenced this pull request Nov 3, 2016
@jdddog
Copy link

jdddog commented Nov 30, 2016

What if you want to include assets from node_modules, which seems like a fairly common use case?

  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico",
        "../node_modules/materialize-css/fonts/roboto"
      ]

In this case angular-cli seems to copy the files back into the original directory rather than into the dist folder.

A solution similar to what jeffaxial proposed in this thread would be good: #1463

@phil-cap
Copy link

phil-cap commented Dec 6, 2016

The suggestion from @jdddog is excellent and urgently required. Using fonts and similar assets from node_modules is currently a huge pain in angular-cli.

@jcperez-ch
Copy link

I second @jdddog I am having the same use case, which might be really cool to have. We use internal assets (in a separated repo) for all the projects in the company. So the designer is always updating svg files that get ported to the rest of the projects via npm so

"assets": [
        "assets",
        "favicon.ico",
        "../node_modules/the-designer-repo/svgs"
      ]

would be cool to include and reuse the svgs

@Splaktar
Copy link
Member

Splaktar commented Dec 14, 2016

@phil-cap @jdddog @jcperez-ch I would suggest opening a new issue to track that request/issue. This PR has been merged and isn't the best place for the discussion to take place.

Update: It looks like #3500 and #2880 are tracking this issue. Please add your thoughts there.

@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.

Feature request: angular-cli.json > assets supporting array of values /public vs /src/assets behavior