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
Currently Angular CLI uses Webpack under the hood to bundle and build your Angular application.
46
-
Sadly it doesn't allow you to override its Webpack config in order to add the plugin mentioned in the [Webpack](#webpack) section.
47
-
Without this plugin your build will fail when it tries to build glslify for WebGL plots.
45
+
Since Angular uses webpack under the hood and doesn't allow easily to change it's webpack configuration, there is some work needed using a `custom-webpack` builder to get things going.
48
46
49
-
Currently 2 solutions exists to circumvent this issue:
47
+
1. Install [`@angular-builders/custom-webpack`](https://www.npmjs.com/package/@angular-builders/custom-webpack) and [[email protected]+](https://github.com/hughsk/ify-loader)
48
+
2. Create a new `extra-webpack.config.js` beside `angular.json`.
50
49
51
-
1) If you need to use WebGL plots, you can create a Webpack config from your Angular CLI project with [ng eject](https://github.com/angular/angular-cli/wiki/eject). This will allow you to follow the instructions regarding Webpack.
52
-
2) If you don't need to use WebGL plots, you can make a custom build containing only the required modules for your plots. The clean way to do it with Angular CLI is not the method described in the [Modules](https://github.com/plotly/plotly.js/blob/master/README.md#modules) section of the README but the following:
53
-
54
-
```typescript
55
-
// in the Component you want to create a graph
56
-
import*asPlotlyfrom'plotly.js';
50
+
> extra-webpack.config.json
51
+
```javascript
52
+
module.exports= {
53
+
module: {
54
+
rules: [
55
+
{
56
+
test:/\.js$/,
57
+
include: [
58
+
path.resolve(__dirname, "node_modules/plotly.js")
59
+
],
60
+
loader:'ify-loader'
61
+
}
62
+
]
63
+
},
64
+
};
57
65
```
58
66
67
+
3. Change the builder in `angular.json` to `"@angular-builders/custom-webpack:browser` and configure it correctly to use our new webpack config.
0 commit comments