-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
12,107 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
/build | ||
/mediainfo.d.ts | ||
/types.d.ts | ||
/examples/angular/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,32 @@ | ||
# Mediainfo Angular example | ||
# mediainfo.js Angular example | ||
|
||
**Step #1** | ||
## Step #1: WASM module | ||
|
||
Copy the node_modules/mediainfo.js/dist/MediaInfoModule.wasm to your project's src directory, | ||
Add `MediaInfoModule.wasm` to the `assets` section in the options of the build | ||
target in your `angular.json`. | ||
|
||
**Step #2** | ||
```json | ||
"assets": [ | ||
{ | ||
"input": "node_modules/mediainfo.js/dist", | ||
"glob": "MediaInfoModule.wasm", | ||
"output": "" | ||
} | ||
] | ||
``` | ||
|
||
Modify the angular.json file to add that file to the assets section, in the options of build target | ||
## Step #2: Ignore `fs` and `path` | ||
|
||
"architect": { | ||
"build": { | ||
"builder": "@angular-devkit/build-angular:browser", | ||
"options": { | ||
|
||
... | ||
"assets": [ | ||
"src/assets", | ||
"src/favicon.ico", | ||
"src/MediaInfoModule.wasm" | ||
], | ||
"styles": [ | ||
Add this section to your `package.json`. | ||
|
||
**Step #3** | ||
|
||
Put this browser section in highest level section of package.json (it can be just above dependencies): | ||
|
||
... | ||
"browser": { | ||
"fs": false, | ||
"path": false | ||
}, | ||
"dependencies": { | ||
... | ||
|
||
**Step #4** | ||
|
||
Restart ng serve | ||
```json | ||
"browser": { | ||
"fs": false, | ||
"path": false | ||
}, | ||
``` | ||
|
||
## Credits | ||
|
||
To @David that showed how to do this in [this Stackoverflow question](https://stackoverflow.com/questions/63001079/mediainfo-js-integration-in-angular-8) | ||
|
||
|
||
Based on a [Stack Overflow answer](https://stackoverflow.com/a/63049567) by | ||
[David](https://stackoverflow.com/users/1160794/david). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,45 @@ | ||
{ | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"version": 1, | ||
"newProjectRoot": "projects", | ||
"projects": { | ||
"mediainfoangular": { | ||
"projectType": "application", | ||
"schematics": { | ||
"@schematics/angular:component": { | ||
"style": "scss" | ||
} | ||
}, | ||
"root": "", | ||
"sourceRoot": "src", | ||
"prefix": "app", | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-devkit/build-angular:browser", | ||
"options": { | ||
"outputPath": "dist/mediainfoangular", | ||
"index": "src/index.html", | ||
"main": "src/main.ts", | ||
"polyfills": "src/polyfills.ts", | ||
"tsConfig": "tsconfig.app.json", | ||
"aot": true, | ||
"assets": [ | ||
"src/assets", | ||
{ | ||
"input": "node_modules/mediainfo.js/dist", | ||
"glob": "MediaInfoModule.wasm", | ||
"output": "" | ||
} | ||
|
||
], | ||
"scripts": [] | ||
}, | ||
"configurations": { | ||
"production": { | ||
"fileReplacements": [ | ||
{ | ||
"replace": "src/environments/environment.ts", | ||
"with": "src/environments/environment.prod.ts" | ||
} | ||
], | ||
"optimization": true, | ||
"outputHashing": "all", | ||
"sourceMap": false, | ||
"extractCss": true, | ||
"namedChunks": false, | ||
"extractLicenses": true, | ||
"vendorChunk": false, | ||
"buildOptimizer": true, | ||
"budgets": [ | ||
{ | ||
"type": "initial", | ||
"maximumWarning": "2mb", | ||
"maximumError": "5mb" | ||
}, | ||
{ | ||
"type": "anyComponentStyle", | ||
"maximumWarning": "6kb", | ||
"maximumError": "10kb" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"serve": { | ||
"builder": "@angular-devkit/build-angular:dev-server", | ||
"options": { | ||
"browserTarget": "mediainfoangular:build" | ||
}, | ||
"configurations": { | ||
"production": { | ||
"browserTarget": "mediainfoangular:build:production" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"defaultProject": "mediainfoangular" | ||
} | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"version": 1, | ||
"newProjectRoot": "projects", | ||
"projects": { | ||
"mediainfojs-angular-example": { | ||
"projectType": "application", | ||
"root": "", | ||
"sourceRoot": "src", | ||
"prefix": "app", | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-devkit/build-angular:browser", | ||
"options": { | ||
"outputPath": "dist/mediainfojs-angular-example", | ||
"index": "src/index.html", | ||
"main": "src/main.ts", | ||
"polyfills": "src/polyfills.ts", | ||
"tsConfig": "tsconfig.json", | ||
"aot": true, | ||
"assets": [ | ||
{ | ||
"input": "node_modules/mediainfo.js/dist", | ||
"glob": "MediaInfoModule.wasm", | ||
"output": "" | ||
} | ||
] | ||
} | ||
}, | ||
"serve": { | ||
"builder": "@angular-devkit/build-angular:dev-server", | ||
"options": { | ||
"browserTarget": "mediainfojs-angular-example:build" | ||
}, | ||
"configurations": { | ||
"production": { | ||
"browserTarget": "mediainfojs-angular-example:build:production" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"defaultProject": "mediainfojs-angular-example" | ||
} |
Oops, something went wrong.