Skip to content

Commit f509450

Browse files
committed
add prepublish script
1 parent c8cd9a6 commit f509450

File tree

4 files changed

+71
-9
lines changed

4 files changed

+71
-9
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ $ sudo npm i
6262
$ node devServer.js
6363
```
6464

65+
and open `localhost:5000/example`
66+
6567
Build production `js`, `min.js` code
6668

6769
```

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"scripts": {
1010
"test": "echo \"Error: no test specified\" && exit 1",
11-
"watch": "NODE_ENV=0 webpack -w",
11+
"prepublish": "npm run build && npm run prod",
1212
"build": "rm -rf ./lib && babel -w --stage 0 src --out-dir lib",
1313
"prod": "NODE_ENV=0 webpack --config webpack.prod.config.js && NODE_ENV=1 webpack --config webpack.prod.config.js"
1414
},
@@ -48,7 +48,6 @@
4848
"d3": "^3.5.6",
4949
"d3-shape": "^0.5.1",
5050
"react-d3-core": "^1.1.6",
51-
"react-dom": "^0.14.0",
52-
"react-faux-dom": "^2.1.0"
51+
"react-dom": "^0.14.0"
5352
}
5453
}

src/components/scatter.jsx

-6
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@ export default class Scatter extends Component {
6969
}
7070
}
7171
)
72-
73-
74-
// ({
75-
// size: symbolSize * symbolSize,
76-
// type: D3Shape.symbolCross
77-
// })()
7872

7973
return (
8074
<path

webpack.config.prod.js

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
'use strict';
2+
3+
var path = require('path'),
4+
webpack = require('webpack'),
5+
nodeModulesPath = path.join(__dirname, 'node_modules');
6+
7+
var js_root = './lib/';
8+
var js_dist = __dirname;
9+
10+
// 0 stands for development, 1 stands for production
11+
// for development mode: NODE_ENV=0 webpack
12+
// for production mode: NODE_ENV=1 webpack
13+
var ENV = !!(+process.env.NODE_ENV || 0);
14+
15+
module.exports = [{
16+
name: 'prod',
17+
entry: {
18+
"react-d3-shape": js_root + 'index.js',
19+
},
20+
21+
output: {
22+
libraryTarget: "var",
23+
library: "ReactD3Shape",
24+
path: js_dist,
25+
filename: ENV ? '[name].min.js' : '[name].js'
26+
},
27+
28+
module: {
29+
loaders: [{
30+
loader: 'babel-loader',
31+
test: [/\.jsx$/, /\.js$/],
32+
exclude: /node_modules/,
33+
query: {
34+
presets: ['react', 'es2015', 'stage-0']
35+
}
36+
}, {
37+
test: /\.css$/,
38+
loader: 'style-loader!css-loader'
39+
}],
40+
},
41+
42+
resolve: {
43+
extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx']
44+
},
45+
46+
externals: {
47+
//don't bundle the 'react' npm package with our bundle.js
48+
//but get it from a global 'React' variable
49+
'react': 'React',
50+
'react-dom': 'ReactDOM',
51+
'd3': 'd3'
52+
},
53+
54+
plugins: ENV ? [
55+
new webpack.optimize.UglifyJsPlugin({
56+
sourceMap: true,
57+
mangle: false
58+
}),
59+
new webpack.ProvidePlugin({
60+
'd3': 'd3'
61+
})
62+
] : [
63+
new webpack.ProvidePlugin({
64+
'd3': 'd3'
65+
})
66+
]
67+
}];

0 commit comments

Comments
 (0)