Skip to content

Commit 3554894

Browse files
committed
Remove gulp scripts for examples and use webpack
This drops a few scripts from package.json (mostly the publishing ones).
1 parent ad60c47 commit 3554894

File tree

9 files changed

+1325
-1690
lines changed

9 files changed

+1325
-1690
lines changed

example/src/.gitignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

example/src/components/app.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import React from 'react';
2+
3+
import DoughnutExample from './doughnut';
4+
import DynamicDoughnutExample from './dynamic-doughnut';
5+
import PieExample from './pie';
6+
import LineExample from './line';
7+
import BarExample from './bar';
8+
import HorizontalBarExample from './horizontalBar';
9+
import RadarExample from './radar';
10+
import PolarExample from './polar';
11+
import BubbleExample from './bubble';
12+
import ScatterExample from './scatter';
13+
import MixedDataExample from './mix';
14+
import RandomizedDataLineExample from './randomizedLine';
15+
import CrazyDataLineExample from './crazyLine';
16+
import LegendOptionsExample from './legend-options';
17+
import LegendHandlersExample from './legend-handlers';
18+
19+
export default class App extends React.Component {
20+
render() {
21+
return (
22+
<div>
23+
<hr />
24+
<DoughnutExample />
25+
<hr />
26+
<DynamicDoughnutExample />
27+
<hr />
28+
<PieExample />
29+
<hr />
30+
<LineExample />
31+
<hr />
32+
<BarExample />
33+
<hr />
34+
<HorizontalBarExample />
35+
<hr />
36+
<RadarExample />
37+
<hr />
38+
<PolarExample />
39+
<hr />
40+
<BubbleExample />
41+
<hr />
42+
<ScatterExample />
43+
<hr />
44+
<MixedDataExample />
45+
<hr />
46+
<RandomizedDataLineExample />
47+
<hr />
48+
<CrazyDataLineExample />
49+
<hr />
50+
<LegendOptionsExample />
51+
<hr />
52+
<LegendHandlersExample />
53+
</div>
54+
);
55+
}
56+
}
File renamed without changes.

example/src/example.js

Lines changed: 0 additions & 59 deletions
This file was deleted.

example/src/index.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<!doctype html>
22
<head>
33
<title>react-chartjs-2</title>
4-
<link rel="stylesheet" href="example.css">
54
</head>
65
<body>
76
<div class="container">
@@ -16,7 +15,4 @@ <h2><a href="https://github.com/jerairrest/react-chartjs-2">View project on GitH
1615
Copyright &copy; 2017 Jeremy Ayerst.
1716
</div>
1817
</div>
19-
<script src="common.js"></script>
20-
<script src="bundle.js"></script>
21-
<script src="example.js"></script>
2218
</body>

example/src/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
4+
const MOUNT_NODE = document.getElementById('app');
5+
6+
const render = () => {
7+
const App = require('./components/app').default;
8+
9+
ReactDOM.render(<App />, MOUNT_NODE);
10+
};
11+
12+
render();
13+
14+
if (module.hot) {
15+
module.hot.accept(['./components/app'], () =>
16+
setImmediate(() => {
17+
ReactDOM.unmountComponentAtNode(MOUNT_NODE);
18+
render();
19+
})
20+
);
21+
}

example/webpack.config.babel.js

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import path from 'path';
2+
import webpack from 'webpack';
3+
import HtmlWebpackPlugin from 'html-webpack-plugin';
4+
import ExtractTextPlugin from 'extract-text-webpack-plugin';
5+
6+
const inExamples = loc => path.resolve(__dirname, loc);
7+
8+
const env = process.env.NODE_ENV || 'development';
9+
const __DEV__ = env === 'development';
10+
11+
const config = {
12+
entry: {
13+
app: [
14+
inExamples('src/index.js'),
15+
inExamples('src/example.css')
16+
]
17+
},
18+
module: {
19+
rules: [
20+
{
21+
test: /\.js$/,
22+
exclude: /node_modules/,
23+
loader: 'babel-loader'
24+
},
25+
{
26+
test: /\.css$/,
27+
loader: ExtractTextPlugin.extract({
28+
fallback: 'style-loader',
29+
use: 'css-loader'
30+
})
31+
}
32+
]
33+
},
34+
resolve: {
35+
alias: {
36+
'react-chartjs-2': '../../../src'
37+
}
38+
},
39+
output: {
40+
path: inExamples('dist'),
41+
filename: '[name].js'
42+
},
43+
plugins: [
44+
new webpack.DefinePlugin({
45+
'process.env': {
46+
NODE_ENV: JSON.stringify(env)
47+
},
48+
}),
49+
new ExtractTextPlugin({
50+
filename: '[name].css',
51+
disable: __DEV__
52+
}),
53+
new HtmlWebpackPlugin({
54+
template: inExamples('src/index.html'),
55+
inject: true,
56+
minify: {
57+
removeComments: true,
58+
collapseWhitespace: true,
59+
removeRedundantAttributes: true,
60+
useShortDoctype: true,
61+
removeEmptyAttributes: true,
62+
removeStyleLinkTypeAttributes: true,
63+
keepClosingSlash: true,
64+
minifyJS: true,
65+
minifyCSS: true,
66+
minifyURLs: true
67+
}
68+
})
69+
],
70+
devServer: {
71+
contentBase: path.join(__dirname, 'src'),
72+
historyApiFallback: true,
73+
hot: true,
74+
inline: true,
75+
port: 8000,
76+
stats: {
77+
cached: false
78+
}
79+
}
80+
};
81+
82+
if (__DEV__) {
83+
config.plugins.push(
84+
new webpack.NoEmitOnErrorsPlugin(),
85+
new webpack.HotModuleReplacementPlugin()
86+
);
87+
}
88+
else {
89+
config.plugins.push(
90+
new webpack.optimize.ModuleConcatenationPlugin(),
91+
92+
new webpack.LoaderOptionsPlugin({
93+
minimize: true,
94+
debug: false,
95+
}),
96+
97+
new webpack.optimize.UglifyJsPlugin({
98+
comments: false,
99+
compress: {
100+
warnings: false,
101+
screw_ie8: true,
102+
conditionals: true,
103+
unused: true,
104+
comparisons: true,
105+
sequences: true,
106+
dead_code: true,
107+
evaluate: true,
108+
if_return: true,
109+
join_vars: true,
110+
},
111+
mangle: {
112+
screw_ie8: true
113+
},
114+
output: {
115+
comments: false,
116+
screw_ie8: true
117+
}
118+
})
119+
);
120+
}
121+
122+
export default config;

package.json

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"babel-cli": "^6.26.0",
2525
"babel-core": "^6.18.2",
2626
"babel-eslint": "^4.1.3",
27+
"babel-loader": "^7.1.1",
2728
"babel-plugin-external-helpers": "^6.22.0",
2829
"babel-preset-es2015": "^6.13.2",
2930
"babel-preset-react": "^6.11.1",
@@ -36,25 +37,30 @@
3637
"chai": "^3.5.0",
3738
"chart.js": "^2.3.0",
3839
"cross-env": "^5.0.0",
40+
"css-loader": "^0.28.5",
3941
"debug": "^2.4.1",
4042
"enzyme": "^2.6.0",
4143
"eslint": "^1.6.0",
4244
"eslint-plugin-react": "^3.5.1",
45+
"extract-text-webpack-plugin": "^3.0.0",
46+
"gh-pages": "^1.0.0",
4347
"gulp": "^3.9.0",
48+
"html-webpack-plugin": "^2.30.1",
4449
"jsdom": "^9.8.3",
4550
"mocha": "^3.1.2",
4651
"rcolor": "^1.0.1",
4752
"react": "^0.14 || ^15.0.0-rc || ^15.0",
4853
"react-addons-test-utils": "^15.3.2",
49-
"react-component-gulp-tasks": "git+https://github.com/gor181/react-component-gulp-tasks.git",
5054
"react-dom": "^0.14 || ^15.0.0-rc || ^15.0",
5155
"rimraf": "^2.6.1",
5256
"rollup": "^0.47.6",
5357
"rollup-plugin-babel": "^3.0.2",
5458
"rollup-plugin-commonjs": "^8.1.0",
5559
"rollup-plugin-node-resolve": "^3.0.0",
5660
"rollup-plugin-uglify": "^2.0.1",
57-
"sinon": "^1.17.6"
61+
"sinon": "^1.17.6",
62+
"webpack": "^3.5.5",
63+
"webpack-dev-server": "^2.7.1"
5864
},
5965
"peerDependencies": {
6066
"chart.js": "^2.3",
@@ -73,13 +79,13 @@
7379
"build:umd": "cross-env BABEL_ENV=rollup NODE_ENV=development rollup -c -o dist/react-chartjs-2.js",
7480
"build:umd:min": "cross-env BABEL_ENV=rollup NODE_ENV=production rollup -c -o dist/react-chartjs-2.min.js",
7581
"build": "npm run clean && npm run build:cjs && npm run build:es && npm run build:umd && npm run build:umd:min",
76-
"examples": "gulp dev:server",
82+
"examples": "webpack-dev-server --config example/webpack.config.babel.js --progress",
83+
"examples:clean": "rimraf example/dist",
84+
"examples:build": "cross-env BABEL_ENV=development NODE_ENV=production webpack --config example/webpack.config.babel.js --progress",
85+
"examples:deploy": "npm run examples:clean && npm run examples:build && gh-pages -d example/dist",
86+
"start": "npm run examples",
7787
"lint": "eslint ./; true",
78-
"publish:site": "cross-env NODE_ENV=production gulp publish:examples",
79-
"release": "cross-env NODE_ENV=production gulp release",
80-
"start": "gulp dev",
8188
"test": "mocha test/config/setup.js test/__tests__/**/*",
82-
"watch": "gulp watch:lib",
8389
"storybook": "start-storybook -p 6006",
8490
"build-storybook": "build-storybook"
8591
},

0 commit comments

Comments
 (0)