-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add Building.md #2654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Building.md #2654
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b0e9209
Add instruction to build with Angular CLI
TomDemulierChevret 794a175
Fix inter section link & json example
TomDemulierChevret 757a77c
first cut BUILDING.md file
etpinard 54c2e60
fixups
etpinard 3cf0c5c
add BUILDING.md to lower-case-only whitelist
etpinard 9199e8e
clean up a few typos & style in BUILDING.md
alexcjohnson b8e1bea
update link & style in README.md
alexcjohnson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,78 @@ | ||
# Building plotly.js | ||
|
||
## Webpack | ||
|
||
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. | ||
|
||
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`: | ||
|
||
```js | ||
... | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
loader: 'ify-loader' | ||
} | ||
] | ||
}, | ||
... | ||
``` | ||
|
||
## Browserify | ||
|
||
Given source file: | ||
|
||
```js | ||
// file: index.js | ||
|
||
var Plotly = require('plotly.js'); | ||
|
||
// .... | ||
``` | ||
|
||
then simply run, | ||
|
||
|
||
``` | ||
browserify index.js > bundle.js | ||
``` | ||
|
||
to trim meta information (and thus save a few bytes), run: | ||
|
||
|
||
``` | ||
browserify -t path/to/plotly.js/tasks/util/compress_attributes.js index.js > bundle.js | ||
``` | ||
|
||
## Angular CLI | ||
|
||
Currently Angular CLI use Webpack under the hood to bundle and build your Angular application. | ||
Sadly it doesn't allow to override its Webpack config, and therefore to use the plugin mentioned in the [Webpack](#webpack) section. | ||
Without this plugin your build will fail when it tries to build glslify for WebGL plots. | ||
|
||
Currently 2 solutions exists to circumvent this issue : | ||
|
||
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. | ||
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 : | ||
|
||
```typescript | ||
// in the Component you want to create a graph | ||
import * as Plotly from 'plotly.js'; | ||
``` | ||
|
||
```json | ||
// in src/tsconfig.app.json | ||
// List here the modules you want to import | ||
// this exemple is for scatter plots | ||
{ | ||
"compilerOptions": { | ||
"paths": { | ||
"plotly.js": [ | ||
"../node_modules/plotly.js/lib/core.js", | ||
"../node_modules/plotly.js/lib/scatter.js" | ||
] | ||
} | ||
} | ||
} | ||
``` |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
##
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> b8e1bea