Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 -- Angular-CLI - Exclude folders from automatic build watchers

angular-cli beta.16, using webpack. project created with the CLI

Hi,

This is my project structure :

- server - server.js - src - app - compoents & co - assets - index.html

I'm using server.js for handling upload request coming from one of my angular component. The file is uploaded and I want to put it in the assets directory, so i can use it after in the app.

The problem is when I do such work (uploading a file in the assets folders) that make my angular-cli to re build the entire app (because it detect a change in my files), so the app is reloaded in the browser and i cannot use it.

Is there a way to exclude somes folders (for me the 'assets' folder) for the "watch build" task of the CLI? so the CLI don't build the app again when i'm putting a new file into it?

Thank you guys !

like image 543
Seballot Avatar asked Oct 05 '16 08:10

Seballot


1 Answers

I don't believe there is. However you are thinking about this backward, or maybe I didn't understand the question considering there is so many upvotes.

I want to put it in the assets directory, so i can use it after in the app.

This doesn't add up. What do you mean use it in the app ? You already have those files in the app, you said it yourself :

I'm using server.js for handling upload request coming from one of my angular component.

..from one of my angular component..


Let's look at a scenario where you could do what you are asking for. The files get uploaded to assets. Now what ?

Webpack-dev-server serve files from memory. With --watch, it add watchers so it knows when a file change and it updates its memory. If the files haven't changed (or in an imaginary world where the directory is not watched like you asked), then there is nothing new to serve. In other words you won't be able to have something like src="assets/myNewlyUploadedAsset.png" anywhere in your app, it will return a 404.


I assume you want to do that because on your server.js you made some changes to those files. So what's your option to get those changes ?

You store it somewhere else than in the assets. That's what you should do, because your app folder really isn't the place to upload user content.

like image 126
Ced Avatar answered Nov 17 '22 19:11

Ced