1

OS: Windows 10

Using Angular-CLI

My end goal is to have a package set up that contains the following file structure within the dist folder after runing npm run packagr:

+--src
|    +-- app
|    +-- assets

I have done the following set in angular-cli.json according to the documentation:

"apps" : [
    {
         "root": "src",
         "outDir": "dist",
         "assets": [
             {
                 "glob": "**/*",
                 "input": "../styles",
                 "output" : "./assets/styles"
             }
         ], ...
     }, ...
]

According to the documentation this should target the assets/styles folder inside of my src directory, grab everything in it, then send it to dist as a copy. It will not do that, and I have done many iterations of this. All I want is my styles folder inside the dist directory, so when I run npm pack it is in the package and ready for upload.

package.json

{
  "name": "c2c-component-library",
  "version": "0.0.3",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "packagr": "ng-packagr -p ng-package.json"
  },
  "private": false,
  "dependencies": {
    "@angular/animations": "^5.2.0",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "bootstrap": "^4.0.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.5.6",
    "zone.js": "^0.8.19"
  },
  "devDependencies": {
    "@angular/cli": "1.6.8",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "ng-packagr": "^2.0.0",
    "protractor": "~5.1.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3"
  }
}
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Mark Hill
  • 1,769
  • 2
  • 18
  • 33
  • Can you post your package.json? – E_net4 Feb 13 '18 at 17:23
  • @E_net4 posted it for you there – Mark Hill Feb 13 '18 at 17:26
  • *"this should target the `assets/styles` folder inside of my src"* - on what basis? I'd expect that to be `"input": "assets/styles"`, those patterns start from `src`. But the default `"assets": ["assets"]` would copy everything anyway, surely? – jonrsharpe Feb 13 '18 at 17:28
  • I'm dealing with the exact same thing. I've looked at other component libs, they all use gulp to run some tasks. I've been avoiding using gulp and trying to find a way to do it with `ng-packagr`. I'm curious to see if anyone has a better way to do it. If not, when I come up with the solution, I'll post it here. – Bunyamin Coskuner Feb 13 '18 at 17:31
  • @jonrsharpe on the basis of the documentation. I thought just putting the assets in there would that as well. I've changed file permissions and everything. – Mark Hill Feb 13 '18 at 17:32
  • Could you link to it? By default the settings are `"assets": ["assets", "favicon.ico"]`, both of which are at the top of `/src`, and as far as I'm aware that would include directories within `src/assets`. Similarly the default is to put both of those things at the root of `/dist` when building. So it's unclear why you thought this would need special config. Is this something that happens *after* `ng build`? What is `ng-packagr` doing, what's in `ng-package.json`? – jonrsharpe Feb 13 '18 at 17:34
  • That's what I'm trying to figure out. – Mark Hill Feb 13 '18 at 17:35
  • *What's* what you're trying to figure out? Please [edit] to clarify what you're trying to achieve and give a [mcve] with the relevant configuration. – jonrsharpe Feb 13 '18 at 17:38
  • @jonrsharpe I'm having the same problem with OP. I've done what `ng-packagr` docs said. It only compiles my components and makes their html and css inline. It does not even create a css from my `styles.sass`. I think I'm missing a point but haven't figured it out yet. – Bunyamin Coskuner Feb 13 '18 at 17:38
  • Related: https://stackoverflow.com/q/46442949/3001761 – jonrsharpe Feb 13 '18 at 17:45
  • @jonrsharpe I have used that resolution, and it failed. – Mark Hill Feb 13 '18 at 17:50
  • Have you? Is `/styles` actually at the same level as `/src`? Note that we can't see the starting package structure, which would be part of a [mcve]. – jonrsharpe Feb 13 '18 at 17:51
  • @jonrsharpe also the file structure is posted in the OP if you looked. You'll see that they are not on the same level – Mark Hill Feb 13 '18 at 17:55
  • But what you've shown *doesn't include `/styles`*, which is what your `assets` object is referring to. From the description that's *inside `/assets`*, in which case it's not clear why you're trying to match it by going *up* a directory from `/src`. I'm simply asking for more information. – jonrsharpe Feb 13 '18 at 17:57
  • @jonrsharpe I have included that in the OP. I show where I'm trying to refer to the styles directory based on the structure that I have provided, and this is all based on the packagr documentation. I don't know what else to give you here. – Mark Hill Feb 13 '18 at 17:59
  • First: I assume the *source* you're referring to is `/src/assets/styles`. That would be good to actually show in the illustration of the file structure, given that's what seem to be asking about. Second: it's unclear why you thought that `../styles`, starting from `/src`, would get you to that directory. – jonrsharpe Feb 13 '18 at 18:01
  • 1
    Please note that you do not get to tell other users where they may or may not contribute. Also *"back and forth"* implies that I'm getting anything back besides your rudeness; you still have not actually edited the question. That said, given that you don't want help from me and I'm certainly not minded to waste any more of my time on your problems: have a nice day. – jonrsharpe Feb 13 '18 at 18:16

0 Answers0