I used D3 v3 with webpack, which was simple with one package. Now that D3 v4 has become modular with separate packages, I cannot bundle them into a single package.
I referenced the mbostock article below using the cumulative file, but it does not say that it cannot load d3 from index.js. Can someone help me with how to link them using webpack?
EDIT 1: I removed d3 from the collapse options and the drive was working fine. I explained the steps below
- Installed D3 v4.
- Added drive configuration and save to. / dist / d 3.min.js
- bound web package to. / dist / d 3.min.js
- tried resolve.alias in webpack and demanded ("d3") in one home.js. But no luck what he says.
can't resolve d3 module in home.js
- tried webpack.Provideplugin in home.js. Still error above.
Can someone help me with downloading this d3?
Rollup.js
import node from "rollup-plugin-node-resolve"; export default { entry: "index.js", format: "umd", moduleName: "d3", plugins: [node()], dest: "./dist/d3.js" };
index.js
export * from "d3-selection"; export * from "d3-zoom"; export * from "d3-scale"; export * from "d3-drag"; export * from "d3-force"; export * from "d3-axis";
webpack.config.js
var webpack = require('webpack') var path = require('path') module.exports = { entry: [ //"./dist/d3-combined.js", "./client/home.js" ,"./client/pages.js" ,"./client/graph.js" ,"./client/orient_databases.js" ,"./node_modules/d3/d3.js", ,"./public/jquery-2.2.4.min.js" ] ,output: { path: path.join(__dirname,'dist') // ,path: '/static' ,publicPath: 'http://localhost:3000/scripts/' ,filename: 'bundle.js' } ,plugins :[ new webpack.ProvidePlugin({ jquery : "jquery" }), new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }) ] ,module: { // avoid webpack trying to shim process noParse: /es6-promise\.js$/, loaders: [ { test: /\.vue$/, loader: 'vue' }, { test: /\.js$/, // excluding some local linked packages. // for normal use cases only node_modules is needed. exclude: /node_modules|vue\/dist|vue-router\/|vue-loader\/|vue-hot-reload-api\//, loader: 'babel-loader', query : { presets : ['es2015'] //,optional : ["runtime"] } } ] } ,resolve : { //root : [path.resolve('./node_modules')], alias : [ {"d3": path.join(__dirname,"dist/d3.min.js") } ], modulesDirectories : ["node_modules"] } }