diff --git a/.gitignore b/.gitignore index 1c01960..451228e 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,10 @@ jspm_packages .node_repl_history # TS generated files -ts-output \ No newline at end of file +ts-output + +# Build files +dist + +# Temporary files +tmp diff --git a/.travis.yml b/.travis.yml index df11b5f..6a3c3ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,10 @@ node_js: install: - npm install script: -- npm run check-coverage +- npm run build +after_success: +- npm install deploy-to-gh-pages +- node_modules/.bin/deploy-to-gh-pages dist +env: + global: + secure: ZqPfmcWEqy0An6YjrmqBZ0hmiRIHHrK1q6qEc8jY556GCyqdDdC2vEM9Ad2H4OTNsJIccyOZK/ugJL6X5PdQ/xTnHavenQty8w81Efmx93MtI7vO1q/tYW0sul7s869lqHWxUoDoQn+Eo8wGY1Ez4wswEvvI/fL0HPqhrRADBtjGPK13eBUenygezg8OcLGG+yHkbWkt3Pl+spRJaxHhN9KlVdf6MBBoBcV/3cTyDjl7HATe9KsyXzkvJO8IgAXJSLekKFhGGR1CQR/qK6V2J6hUXZMyoXl+JOcqg6gBkxFBvzmuDaX+XNyP0LVcvnxAHbNZZegm5XDXqdVpI9oRzO6YqEh5tPC2GByR5w7ZvdydmuCeC7kG97DM3V9EQ5jTgqTIK+mMGklM8fE7Sn9WlqQyX2oJ4yGl0mYIx+eCd3vKeduL8u4HhlYiQdY4jFRyhooykgw6LkaUx5BppSE3qwl1jNn8vhNk6kFJ9HsWD6lOTBkCVF1q6jsMBO0jhy/pARMeCx2qbxRMMkjy49YjL9MEex9qPTIbmL+Dlmyf1fSmjYwYZ0D4eW+J45pPBvBhvwy2mCxgsXcSYlUEfa87XQqnM1/udKpaJ/0/jblr5dYUgJBao4s8s/9nmGKmWX8zlPJcRIQylCHkrK6klyUntEu1si7yCJ3ii+BoDC8U0Vs= diff --git a/package.json b/package.json index ae09a38..4ae56f9 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "cover:watch": "nodemon --quiet --watch src --ext ts,tsx --exec npm run cover", "check-coverage": "nyc --check-coverage --statements 80 --branches 80 --functions 80 --lines 80 npm test", "lint": "tslint \"src/**/*.tsx\" \"src/**/*.ts\"", - "start": "webpack-dev-server --env.dev --hot" + "start": "webpack-dev-server --env.dev --hot", + "build": "npm run check-coverage && rimraf dist && webpack --env.prod" }, "repository": { "type": "git", @@ -58,7 +59,9 @@ "jsdom": "9.4.1", "nodemon": "1.10.0", "nyc": "7.1.0", + "progress-bar-webpack-plugin": "1.9.0", "react-addons-test-utils": "15.3.0", + "rimraf": "2.5.4", "sinon": "1.17.5", "tslint": "3.14.0", "tslint-react": "0.4.0", diff --git a/webpack.config.js b/webpack.config.js index 71e8366..2e8995f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,6 +2,7 @@ const {resolve} = require('path') const webpack = require('webpack') const HtmlWebpackPlugin = require('html-webpack-plugin') const {getIfUtils, removeEmpty} = require('webpack-config-utils') +const ProgressBarPlugin = require('progress-bar-webpack-plugin') module.exports = env => { const {ifProd, ifNotProd} = getIfUtils(env) @@ -14,7 +15,7 @@ module.exports = env => { filename: '[name].[hash].js', path: resolve('dist'), // Include comments with information about the modules. - pathinfo: ifNotProd(), + pathinfo: ifNotProd(), }, resolve: { @@ -23,7 +24,7 @@ module.exports = env => { '.js', '.ts', '.tsx' - ] + ] }, devtool: ifProd('source-map', 'cheap-module-source-map'), @@ -34,15 +35,26 @@ module.exports = env => { {test: /\.css$/, loaders: ['style', 'css']}, ], }, + // This is required, when using Hot Code Replacement between multiple calls to the compiler. - recordsPath: resolve(__dirname, './webpack-records.json'), + recordsPath: resolve(__dirname, './tmp/webpack-records.json'), plugins: removeEmpty([ + // Add nice progress bar + new ProgressBarPlugin(), + new HtmlWebpackPlugin({ template: resolve('src','index.html') }), + // Set NODE_ENV to enable production react version + new webpack.DefinePlugin({ + 'process.env': { + NODE_ENV: ifProd('"production"', '"development"') + } + }), + ifProd(new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', })), @@ -52,6 +64,24 @@ module.exports = env => { name: 'inline', })), + // Deduplicate node modules dependencies + ifProd(new webpack.optimize.DedupePlugin()), + + // Default webpack build options + ifProd(new webpack.LoaderOptionsPlugin({ + debug: false + })), + + // Uglify bundles + ifProd(new webpack.optimize.UglifyJsPlugin({ + compress: { + warnings: false, + }, + output: { + comments: false + } + })) + ]), } -} \ No newline at end of file +}