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
For plotly.js to build with Webpack you will need to install [ify-loader@v1.1.0+](https://github.com/hughsk/ify-loader) and add it to your `webpack.config.json`. This adds Browserify transform compatibility to Webpack which is necessary for some plotly.js dependencies.
6
+
7
+
A repo that demonstrates how to build plotly.js with Webpack can be found [here](https://github.com/plotly/plotly-webpack). In short add `ify-loader` to the `module` section in your `webpack.config.js`:
8
+
9
+
```js
10
+
...
11
+
module: {
12
+
rules: [
13
+
{
14
+
test:/\.js$/,
15
+
loader:'ify-loader'
16
+
}
17
+
]
18
+
},
19
+
...
20
+
```
21
+
22
+
## Browserify
23
+
24
+
Given source file:
25
+
26
+
```js
27
+
// file: index.js
28
+
29
+
var Plotly =require('plotly.js');
30
+
31
+
// ....
32
+
```
33
+
34
+
then simply run,
35
+
36
+
37
+
```
38
+
browserify index.js > bundle.js
39
+
```
40
+
41
+
to trim meta information (and thus save a few bytes), run:
Currently Angular CLI use Webpack under the hood to bundle and build your Angular application.
51
+
Sadly it doesn't allow to override its Webpack config, and therefore to use the plugin mentioned in the [Webpack](#webpack) section.
52
+
Without this plugin your build will fail when it tries to build glslify for WebGL plots.
53
+
54
+
Currently 2 solutions exists to circumvent this issue :
55
+
56
+
1) If you need to use WebGL plots, you can create a Webpack config from your Angular CLI projet with [ng eject](https://github.com/angular/angular-cli/wiki/eject). This will allow you to follow the instructions regarding Webpack.
57
+
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 :
For plotly.js to build with Webpack you will need to install [ify-loader@v1.1.0+](https://github.com/hughsk/ify-loader) and add it to your `webpack.config.json`. This adds Browserify transform compatibility to Webpack which is necessary for some plotly.js dependencies.
110
-
111
-
A repo that demonstrates how to build plotly.js with Webpack can be found [here](https://github.com/rreusser/plotly-webpack). In short add `ify-loader` to the `module` section in your `webpack.config.js`:
112
-
```js
113
-
...
114
-
module: {
115
-
rules: [
116
-
{
117
-
test:/\.js$/,
118
-
loader:'ify-loader'
119
-
}
120
-
]
121
-
},
122
-
...
123
-
```
124
-
125
-
#### Building plotly.js with Angular CLI
126
-
127
-
Currently Angular CLI use Webpack under the hood to bundle and build your Angular application.
128
-
Sadly it doesn't allow to override its Webpack config, and therefore to use the plugin mentioned in [Building plotly.js with Webpack](#building-plotlyjs-with-webpack).
129
-
Without this plugin your build will fail when it tries to build glslify for GLSL plots.
130
-
131
-
Currently 2 solutions exists to circumvent this issue :
132
-
1) If you need to use GLSL plots, you can create a Webpack config from your Angular CLI projet with [ng eject](https://github.com/angular/angular-cli/wiki/eject).
133
-
This will allow you to follow the instructions regarding Webpack.
134
-
2) If you don't need to use GLSL plots, you can make a custom build containing only the required modules for your plots.
135
-
The clean way to do it with Angular CLI is not the method described in [Modules](#modules) but the following :
136
-
```typescript
137
-
// in the Component you want to create a graph
138
-
import*asPlotlyfrom'plotly.js';
139
-
```
140
-
141
-
```json
142
-
// in src/tsconfig.app.json
143
-
// List here the modules you want to import
144
-
// this exemple is for scatter plots
145
-
{
146
-
"compilerOptions": {
147
-
"paths": {
148
-
"plotly.js": [
149
-
"../node_modules/plotly.js/lib/core.js",
150
-
"../node_modules/plotly.js/lib/scatter.js"
151
-
]
152
-
}
153
-
}
154
-
}
155
-
```
109
+
Building instructions using `webpack`, browserify` and other build frameworks in [`BUILDING.md`](https://github.com/plotly/plotly.js/blob/master/BUILDING.md)
0 commit comments