You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make two new commands for adding and deleting 3rd party libraries. - npm run ng-add-3rd-party - npm run ng-delete-3rd-party Update README.md to explain the steps needed.
Copy file name to clipboardExpand all lines: README.md
+36-2Lines changed: 36 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ Than install JavaScript dependencies with **npm**.
24
24
npm install
25
25
```
26
26
27
-
Initialize Agular and compile and publish code with these two commands.
27
+
Initialize Angular and compile and publish code with these two commands.
28
28
29
29
```
30
30
npm run ng-init
@@ -121,7 +121,8 @@ In that case you don't have to delete `public/Ng` directory, running this comman
121
121
***`npm run ng-compile-prod`** - *same as the above but produces minified HTML and CSS files, also compiled JS files from the TS, are minified.
122
122
Note that original JS files in your `angular_apps` directory (the ones that were not TS) will not be minified by this command. That is because I can't find decent,stable and reliable Gulp plugin that supports minifing ES6, if you know of one let me know.*
123
123
124
-
***`npm run ng-bootstrap`** - *this command is combination of `npm run ng-init` and `npm run ng-compile`, that is it installs Angular and compiles your apps in one go.*
124
+
***`npm run ng-bootstrap`** - *this command is combination of `npm run ng-init`, `npm run ng-add-3rd-party` and `npm run ng-compile`, it installs Angular, installs 3rd party libraries and compiles your apps in one go.
125
+
It is useful when you join existing project. Whith just this command you can build working application on your machine and start working on it.*
125
126
126
127
***`npm run ng-watch`** - *starts watch mode, starts browser and puts your browser in sync, actually all the browsers tabs that have wached URL open.
127
128
When you change, add, move, delete or rename HTML, JS, CSS and TS files in `angular_apps` it will distribute them in real time to `public`. TS files will be compiled to JS first than distributed.
@@ -151,6 +152,37 @@ So if you have, for example, two files in `public/somedir`:*
151
152
*First file `public/somedir/apples.js` would be deleted, second one `public/somedir/oranges.js` would be left.
152
153
Empty directories in distribution (`public`) directory and all nested empty directories will also be deleted if there is any.*
153
154
155
+
***`npm run ng-add-3rd-party`** - *sometimes you have to use third-party libraries in your project. `npm run ng-init` initializes Angular and other standard libraries like `rxjs` but what if you need other libraries as well in your project?
156
+
Best way to explain is by example, so let's say you want to use a third-party library in your project e.g. **angular2-multiselect-dropdown**.
157
+
First install it of course using `npm install angular2-multiselect-dropdown --save`.
158
+
Than open `resources/assets/js/ng-vendor.js` and add library name to the return array of the `vendor_libraries` callback*
159
+
160
+
```JavaScript
161
+
exports.vendor_libraries=function() {
162
+
return [
163
+
'angular2-multiselect-dropdown',
164
+
];
165
+
}
166
+
```
167
+
168
+
*After that run this command `npm run ng-add-3rd-party`.
169
+
Next step is to tell SystemJS where from to load new library. Open `angular_apps/config/<app_name>.config.js` and as a last entry in `map` object add this mapping:*
Than you can use external library in your application.
182
+
File `ng-vendor.js` is located outside of the Angular build directory (`angular_apps`), because it does not need to be published to distribution directory (`public`).*
183
+
184
+
***`npm run ng-delete-3rd-party`** - *opposite of `npm run ng-add-3rd-party`. It will only remove 3rd party libraries from `public/Ng`, it does not remove them from `node_modules`.*
185
+
154
186
***`npm run ng-remove-empty-dirs`** - *removes empty directories and all empty sub-directories from both buld (`angular_apps`) directory and distribution (`public`) directory.
155
187
Unlike `npm run ng-clean`, it does touch `angular_apps` directory and only removes empty directories, thats all it does.
156
188
You can pass `--build` switch to only remove empty directories and sub-directories from `angular_apps` directory or `--dist` switch to remove them only from `public` directory.*
@@ -200,6 +232,8 @@ So for example, **not** ~~`php -S localhost:8080`~~, but `php -S 127.0.0.1:8080`
200
232
201
233
Details on how you integrate your own Angular app from start to finish:
202
234
235
+
> Directory in which this new app will be is gonna be called `NewApp`, in production you should use more descriptive name of what your app does e.g. `Store` or `StockManagement`. That way if you have more Angular applications you can see right away what each one is designated to do soon as you look into `angular-apps` directory.
236
+
203
237
If you already haven't done so trough composer or manually, run these commands.
0 commit comments