Skip to content

Commit

Permalink
Remove gulp scripts for examples and use webpack
Browse files Browse the repository at this point in the history
This drops a few scripts from package.json (mostly the publishing ones).
  • Loading branch information
tusbar committed Aug 18, 2017
1 parent ad60c47 commit 3554894
Show file tree
Hide file tree
Showing 9 changed files with 1,325 additions and 1,690 deletions.
5 changes: 0 additions & 5 deletions example/src/.gitignore

This file was deleted.

56 changes: 56 additions & 0 deletions example/src/components/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from 'react';

import DoughnutExample from './doughnut';
import DynamicDoughnutExample from './dynamic-doughnut';
import PieExample from './pie';
import LineExample from './line';
import BarExample from './bar';
import HorizontalBarExample from './horizontalBar';
import RadarExample from './radar';
import PolarExample from './polar';
import BubbleExample from './bubble';
import ScatterExample from './scatter';
import MixedDataExample from './mix';
import RandomizedDataLineExample from './randomizedLine';
import CrazyDataLineExample from './crazyLine';
import LegendOptionsExample from './legend-options';
import LegendHandlersExample from './legend-handlers';

export default class App extends React.Component {
render() {
return (
<div>
<hr />
<DoughnutExample />
<hr />
<DynamicDoughnutExample />
<hr />
<PieExample />
<hr />
<LineExample />
<hr />
<BarExample />
<hr />
<HorizontalBarExample />
<hr />
<RadarExample />
<hr />
<PolarExample />
<hr />
<BubbleExample />
<hr />
<ScatterExample />
<hr />
<MixedDataExample />
<hr />
<RandomizedDataLineExample />
<hr />
<CrazyDataLineExample />
<hr />
<LegendOptionsExample />
<hr />
<LegendHandlersExample />
</div>
);
}
}
File renamed without changes.
59 changes: 0 additions & 59 deletions example/src/example.js

This file was deleted.

4 changes: 0 additions & 4 deletions example/src/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<!doctype html>
<head>
<title>react-chartjs-2</title>
<link rel="stylesheet" href="example.css">
</head>
<body>
<div class="container">
Expand All @@ -16,7 +15,4 @@ <h2><a href="https://github.com/jerairrest/react-chartjs-2">View project on GitH
Copyright &copy; 2017 Jeremy Ayerst.
</div>
</div>
<script src="common.js"></script>
<script src="bundle.js"></script>
<script src="example.js"></script>
</body>
21 changes: 21 additions & 0 deletions example/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import ReactDOM from 'react-dom';

const MOUNT_NODE = document.getElementById('app');

const render = () => {
const App = require('./components/app').default;

ReactDOM.render(<App />, MOUNT_NODE);
};

render();

if (module.hot) {
module.hot.accept(['./components/app'], () =>
setImmediate(() => {
ReactDOM.unmountComponentAtNode(MOUNT_NODE);
render();
})
);
}
122 changes: 122 additions & 0 deletions example/webpack.config.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import path from 'path';
import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';

const inExamples = loc => path.resolve(__dirname, loc);

const env = process.env.NODE_ENV || 'development';
const __DEV__ = env === 'development';

const config = {
entry: {
app: [
inExamples('src/index.js'),
inExamples('src/example.css')
]
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
}
]
},
resolve: {
alias: {
'react-chartjs-2': '../../../src'
}
},
output: {
path: inExamples('dist'),
filename: '[name].js'
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(env)
},
}),
new ExtractTextPlugin({
filename: '[name].css',
disable: __DEV__
}),
new HtmlWebpackPlugin({
template: inExamples('src/index.html'),
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true
}
})
],
devServer: {
contentBase: path.join(__dirname, 'src'),
historyApiFallback: true,
hot: true,
inline: true,
port: 8000,
stats: {
cached: false
}
}
};

if (__DEV__) {
config.plugins.push(
new webpack.NoEmitOnErrorsPlugin(),
new webpack.HotModuleReplacementPlugin()
);
}
else {
config.plugins.push(
new webpack.optimize.ModuleConcatenationPlugin(),

new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false,
}),

new webpack.optimize.UglifyJsPlugin({
comments: false,
compress: {
warnings: false,
screw_ie8: true,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true,
},
mangle: {
screw_ie8: true
},
output: {
comments: false,
screw_ie8: true
}
})
);
}

export default config;
20 changes: 13 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"babel-cli": "^6.26.0",
"babel-core": "^6.18.2",
"babel-eslint": "^4.1.3",
"babel-loader": "^7.1.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-es2015": "^6.13.2",
"babel-preset-react": "^6.11.1",
Expand All @@ -36,25 +37,30 @@
"chai": "^3.5.0",
"chart.js": "^2.3.0",
"cross-env": "^5.0.0",
"css-loader": "^0.28.5",
"debug": "^2.4.1",
"enzyme": "^2.6.0",
"eslint": "^1.6.0",
"eslint-plugin-react": "^3.5.1",
"extract-text-webpack-plugin": "^3.0.0",
"gh-pages": "^1.0.0",
"gulp": "^3.9.0",
"html-webpack-plugin": "^2.30.1",
"jsdom": "^9.8.3",
"mocha": "^3.1.2",
"rcolor": "^1.0.1",
"react": "^0.14 || ^15.0.0-rc || ^15.0",
"react-addons-test-utils": "^15.3.2",
"react-component-gulp-tasks": "git+https://github.com/gor181/react-component-gulp-tasks.git",
"react-dom": "^0.14 || ^15.0.0-rc || ^15.0",
"rimraf": "^2.6.1",
"rollup": "^0.47.6",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-commonjs": "^8.1.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^2.0.1",
"sinon": "^1.17.6"
"sinon": "^1.17.6",
"webpack": "^3.5.5",
"webpack-dev-server": "^2.7.1"
},
"peerDependencies": {
"chart.js": "^2.3",
Expand All @@ -73,13 +79,13 @@
"build:umd": "cross-env BABEL_ENV=rollup NODE_ENV=development rollup -c -o dist/react-chartjs-2.js",
"build:umd:min": "cross-env BABEL_ENV=rollup NODE_ENV=production rollup -c -o dist/react-chartjs-2.min.js",
"build": "npm run clean && npm run build:cjs && npm run build:es && npm run build:umd && npm run build:umd:min",
"examples": "gulp dev:server",
"examples": "webpack-dev-server --config example/webpack.config.babel.js --progress",
"examples:clean": "rimraf example/dist",
"examples:build": "cross-env BABEL_ENV=development NODE_ENV=production webpack --config example/webpack.config.babel.js --progress",
"examples:deploy": "npm run examples:clean && npm run examples:build && gh-pages -d example/dist",
"start": "npm run examples",
"lint": "eslint ./; true",
"publish:site": "cross-env NODE_ENV=production gulp publish:examples",
"release": "cross-env NODE_ENV=production gulp release",
"start": "gulp dev",
"test": "mocha test/config/setup.js test/__tests__/**/*",
"watch": "gulp watch:lib",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
Expand Down
Loading

0 comments on commit 3554894

Please sign in to comment.