git clone https://gist.github.com/029a732fe90aee341ed0e5e50ac29ba3.git && \
cd 029a732fe90aee341ed0e5e50ac29ba3/ && \
npm install && \
npm run build && \
open index.html
Last active
February 20, 2017 19:49
-
-
Save jfsiii/029a732fe90aee341ed0e5e50ac29ba3 to your computer and use it in GitHub Desktop.
Example for using d3-selection-multi with webpack
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
<!doctype html> | |
<html> | |
<body> | |
<script src="bundle.js"></script> | |
</body> | |
</html> |
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
import * as d3 from 'd3' | |
import 'd3-selection-multi' | |
const body = d3.select('body') | |
const svg = body.append('svg') | |
const rect = svg.append('rect') | |
rect | |
.attr('class', 'box') | |
.attr('x', 20) | |
.attr('y', 20) | |
.attr('height', 100) | |
.attr('width', 200) | |
.attr('fill', 'blue') | |
d3.select('.box') | |
.attrs({ fill: 'red' }) |
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
{ | |
"name": "d3-selection-multi-with-webpack-example", | |
"private": true, | |
"version": "1.0.0", | |
"scripts": { | |
"build": "webpack index.js bundle.js" | |
}, | |
"dependencies": { | |
"d3": "4.6.0", | |
"d3-selection-multi": "1.0.0" | |
}, | |
"devDependencies": { | |
"webpack": "^2.2.1" | |
} | |
} |
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
module.exports = { | |
resolve: { mainFields: [ 'module' ] } | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment