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

Files declared in .angular-cli "assets" are not copied #9230

Closed
rbluethl opened this issue Jan 16, 2018 · 37 comments · Fixed by #11437
Closed

Files declared in .angular-cli "assets" are not copied #9230

rbluethl opened this issue Jan 16, 2018 · 37 comments · Fixed by #11437
Assignees
Labels
area: devkit/build-angular P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity5: regression state: blocked type: bug/fix

Comments

@rbluethl
Copy link

rbluethl commented Jan 16, 2018

Versions

Angular CLI: 1.6.4
Node: 8.9.4
OS: win32 x64

Repro steps

My assets are defined as follows in .angular-cli.json (pretty much the default configuration):

"assets": [
  "assets",
  "favicon.png"
]

However, the files are not copied. Neither the assets folder, nor the favicon.
This only arises with @angular/cli@1.6.4. With 1.6.3, everything works fine.

Mention any other details that might be useful (optional)

Can't really tell you anything else, as no errors or whatsoever are thrown during the build.
The declared assets are just missing in the output directory upon build completion.

@dgsqrs
Copy link

dgsqrs commented Jan 20, 2018

I have the same problem, even with 1.6.5.
All my styles, scss, stored under assets for but correctly imported from root style.scss aren’t available anymore using the —prod flag.

@blovell33
Copy link

I am experiencing this behavior as well, seems to work okay on a Windows 10 box, but seeing the issue on a Windows Server 2008 R2 box, using 1.6.5, ng build --prod -verbose. The favicon.ico and assets folder are missing. Downgraded to 1.6.3 and that worked as expected.

@hansl hansl added os: Windows P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful freq2: medium severity5: regression labels Jan 23, 2018
@filipesilva
Copy link
Contributor

I can't reproduce myself on my Windows 10 machine. @blovell33's report indicates it might be OS related.

@dgsqrs are you on windows as well? If so, what version? Is anyone using symlinks/junction or anything of the sort in their projects?

There was a commit related to asset copy (c7735ab) merged between 1.6.3 and 1.6.4. This commit runs some extra processing on the path. Maybe it's related to the path used. @rbluethl @dgsqrs @blovell33 can you show me the full path for the assets folder in the system where it does not work?

/cc @clydin

@rbluethl
Copy link
Author

C:\Program Files (x86)\Jenkins\{csharpprojectname}\bin\Release\www
System: Windows 10 Enterprise N

Thanks for looking into this.

@enriquegarciagutierrez
Copy link

I'm experiencing the same issue with version 1.6.5 and Windows 7 x64.

If I try downgrading to version 1.6.3 I get the following error after ng build --prod:

Error: Cannot find module '@angular-devkit/core'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\PROJECTS\[examples]\PWA\pwa-ng5\node_modules\@angulardevkit\schematics\src\tree\virtual.js:10:16)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)

Even after installing the package with npm i -D @angular-devkit/core, the ng build --prod command doesn't copy the assets folder either.

@filipesilva
Copy link
Contributor

@enriquegarciagutierrez can you show me the full path for the assets folder in the system where it does not work?

@dgsqrs
Copy link

dgsqrs commented Jan 24, 2018

@filipesilva I'm using Osx but I got the same problem using Ubuntu. I don't know what information I can give you, actually. I did a ng serve and it worked. ng serve --prod does not work and I just saw that the scss are missing, but only those from my assets folder. I have no error, nowhere.

@enriquegarciagutierrez
Copy link

enriquegarciagutierrez commented Jan 24, 2018

Hi @filipesilva

The folder is currently located in C:\PROJECTS\[examples]\PWA\pwa-ng5\src\assets.

I tried creating the project again in C:\pwa-ng5 with version 1.6.5 and surprisingly it's copying favicon.ico but not the assets folder with this configuration in .angular-cli.json:

"apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],

Edit: Never mind, it wasn't copying because there was no content inside assets folder. As soon as I copied some files inside it worked like a charm!

So maybe it has to be with the folder path containing weird characters such as []?

@dgsqrs
Copy link

dgsqrs commented Jan 24, 2018

@filipesilva This issue does not existing using 1.7.0-beta.1 (but I have others)

@filipesilva
Copy link
Contributor

@rbluethl @blovell33 @enriquegarciagutierrez can you try using 1.7.0-beta.1 please?

@filipesilva filipesilva assigned clydin and unassigned filipesilva Jan 24, 2018
@enriquegarciagutierrez
Copy link

enriquegarciagutierrez commented Jan 24, 2018

Hi @filipesilva

Same result using 1.7.0-beta.1:

  • Copies everything to dist if root directory is C:\pwa-ng5\src
  • It doesn't copy anything if root directory is C:\PROJECTS\[examples]\PWA\pwa-ng5\src

Edit: tried renaming [examples] folder to examples and everything works now. Another colleague was having the same issue because she had a . in a folder name (C:\Users\name.lastname\Documents\Projects).

Seems to be something related to certain symbols on folder names.

@blovell33
Copy link

Late seeing this...

Path where it works.
D:\dev\connect\src\Websites\Accounts\Client\src\assets

Path where it does not work.
C:\Program Files (x86)\Jenkins\workspace\(Test) Connect\src\Websites\Accounts\Client\src\assets

I will try later today with with 1.7.0-beta.1

Maybe an issue with special characters in path, I can copy folder to different location and test.

@filipesilva
Copy link
Contributor

filipesilva commented Jan 24, 2018

We've narrowed it down to special characters, yeah. Sorry about that. @clydin is working on a PR in webpack-contrib/copy-webpack-plugin#208 to fix all cases.

BTW for now a workaround is to use a path without special characters.

@oztek22
Copy link

oztek22 commented Feb 7, 2018

I'm also facing same issue while upgrading angular cli from 1.6.6 to 1.6.7.
I have 4-5 different projects and none of them is including assets folder in any(production or dev) build. and can not access it on dev server using ng serve.

Update:
I solved it by removing spaces, brackets and folder name coming in path
D:\Projects\a b c\4. Button(new) is now D:\Projects\vinzentEllissenGermany\4.ButtonNew

@asgher-qureshi
Copy link

I went from 1.6.3 to 1.6.7 and I am having a similar issue. My assets and favicon are not included. The build is done on jenkins:
C:\Program Files (x86)\Jenkins\jobs\mamon\workspace>ng build

@normVent
Copy link

normVent commented Feb 9, 2018

Can report this is an issue for "@angular/cli": "1.4.3" as well, have been using the following all along.

  "assets": [
    "assets",
    "favicon.ico"
  ],

build string
ng build --output-path ..\ngbuild --verbose --target=production --environment=server --aot
Project path
C:\Program Files (x86)\Jenkins\jobs\Travel_Html5\workspace\RIWebUI

@edvards
Copy link

edvards commented Feb 21, 2018

Hi.
Still the same. Assert folder isn't copied.

@angular/cli - 1.7.0
Project folder is: C:\Test (test)\

ejected webpack config:

new CopyWebpackPlugin([
{
"context": "src",
"to": "",
"from": {
"glob": "assets\**\*",
"dot": true
}
},

copy-webpack-plugin debug output:

[copy-webpack-plugin] processing from: '[object Object]' to: ''
[copy-webpack-plugin] determined '' is a 'dir'
[copy-webpack-plugin] begin globbing 'C:/Test \(test\)\src/assets\**\*' with a context of 'C:\Test (test)\src'

@fehrinjt
Copy link

I am also having the same issue still after upgrading to 1.7.0. Running from a Jenkins build process on windows Server 2012 R2. The build folder was under /Program Files (x86). However I moved the build folder to a different directory with no parenthesis and that did fix the problem as @filipesilva indicated.

@github2021
Copy link

issue with angular cli

new CopyWebpackPlugin([
{
"context": "src",
"to": "",
"from": {
"glob": "C:\Users\mrjohn\Desktop\new \folder \7\testing2\src\assets\**\*",
"dot": true
}

should be
"glob": "C:\Users\mrjohn\Desktop\new folder 7\testing2\src\assets\**\*",

@williamchristophercooley

I am able to replicate this issue with Angular-CLI 1.7.2 on Jenkins running on a windows box. It does seems that special characters is the issue.

@ghost
Copy link

ghost commented Mar 10, 2018

got the same problem when i upgraded CLI from 1.6.7 to 1.7.3. downgrading to 1.6.7 fixed it.
and btw when i use the ng serve command in 1.7.3 , it says to open browser on http://localhost:4200/assets, instead of http://localhost:4200/ , not sure related to this issue, but it's fine in version 1.6.7

@lehtiniemi
Copy link

Can confirm that folders with '(' and ')' (like any Dropbox folder) cause the assets not to be included in serve nor build.

@OlegSulima
Copy link

I have the same problem with Jenkins with angular cli 1.6-1.7. I have a project with cli 1.5.5 without problems. Jenkins has a workspace folder C:\Program Files (x86)\Jenkins\workspace. I changed it to C:\jenkinsworkspace and the problem is gone. So problem is in 'Program Files (x86)'

@lehtiniemi
Copy link

lehtiniemi commented Apr 7, 2018 via email

@sri7vasu
Copy link

Is this issue fixed in angular-cli 1.7.4 ? I have the same issue , changing jenkins path will be difficult for me as there are many dependent jobs.

@yusijs
Copy link

yusijs commented Apr 10, 2018

@sri7vasu we had the issue at work with Jenkins where we couldn't just willy nilly change the path - my "fix" was to create an extra task to run after building the project, that copies our assets manually. Very bandaid, so hopefully this will get resolved soon (maybe with the release of 6.0?)

@blovell33
Copy link

still an issue in 6.0.2

@FlorianMathis
Copy link

still an issue @6.0.3

  • ng serve/ng build doesn't deploy asset folder (e.g. the project is under D:__(test)\testproject) [X]
  • ng build deploys asset folder (e.g. the project is under D:\testproject)

As already mentioned: The angular-cli can't handle parenthesis ( '(' and ')' ) in directories correctly.

@vajnorcan
Copy link

On my localhost I'm running:
Node: 8.11.1
Npm: 5.6.0
Angular CLI: 6.0.0
OS: win32 x64
Angular: 5.2.10

On Jenkins (CI) server:
Node: 8.11.2
Npm: 5.6.0
Angular CLI: 6.0.0
OS: win32 x64
Angular: 5.2.10

On my localhost it includes the assets, but not on Jenkins. The only difference is the NodeJS Version. Hope that helps to identify issue a little closer

@filipesilva
Copy link
Contributor

It looks like the tracking issue for this problem in the webpack plugin we use is webpack-contrib/copy-webpack-plugin#231. There seems to be a fix on the way as well: webpack-contrib/copy-webpack-plugin#264

@vajnorcan
Copy link

I was investigating this issue on our Jenkins server and then find out that the issue is the workspace folder contains a space character. If moved to the location where the full path didn't contain any spaces, it compiled properly. Mea culpa, should've checked earlier.

@p3root
Copy link

p3root commented Jun 12, 2018

A half year past now + a major release of angluar and the issue still occurs? Are you kidding me? It can't be that complicated after all this worked a couple releases before.

@rlove
Copy link

rlove commented Jun 28, 2018

This may be related. Currently, I am using to 6.0.7 I have multiple projects in a workspace.
I also have ane empty assets folder.

So my assets read like this:

            "assets": [
              "projects/pname/src/favicon.ico",
              "projects/pname/src/assets"
            ]

If I add web.config to the list like this it won't copy.

            "assets": [
              "projects/pname/src/favicon.ico",
              "projects/pname/src/assets",
              "projects/pname/src/web.config"
            ]

If I add web.config before the assets folder it copies as expected.

            "assets": [
              "projects/pname/src/favicon.ico",
              "projects/pname/src/web.config",
              "projects/pname/src/assets"
            ]

@MaGnaL
Copy link

MaGnaL commented Jul 3, 2018

@filipesilva
Since there has been a new release of the plugin which includes the fix webpack-contrib/copy-webpack-plugin#264, do you plan to include this in 6.1.x?

@filipesilva
Copy link
Contributor

Since the fix is now in copy-webpack-plugin and released, some users should get it straight away. You can force your npm lockfile to use it by doing this:

npm install copy-webpack-plugin@4.5.2 --save-dev
npm uninstall copy-webpack-plugin@4.5.2 --save-dev

This should force your lockfile to recognize the new version and use it inside @angular-devkit/build-angular. Don't forget to uninstall it right after though (the second step), otherwise you can end up with duplicated versions.

I also put up #11437 which bumps our minimum version. It should go in sometime in the 6.1.x life time.

@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 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: devkit/build-angular P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity5: regression state: blocked type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.