From 7f3bdd1603667e1ca0432631c1484afe2b0f5104 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Tue, 30 Aug 2016 19:53:06 +0300 Subject: [PATCH] Update webpack configs + add banner (fixes #89) --- build/webpack.dev.js | 20 ++++++++++---------- build/webpack.prod.js | 7 ++++++- package.json | 3 ++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/build/webpack.dev.js b/build/webpack.dev.js index 3f687a21..5ac0c436 100644 --- a/build/webpack.dev.js +++ b/build/webpack.dev.js @@ -3,12 +3,12 @@ const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin const root = require('./helpers').root; const VERSION = JSON.stringify(require('../package.json').version); - +const IS_PRODUCTION = process.env.NODE_ENV === "production"; // TODO Refactor common parts of config module.exports = { context: root(), - devtool: 'cheap-module-source-map', + devtool: 'source-map', debug: false, resolve: { @@ -43,22 +43,22 @@ module.exports = { poll: true }, port: 9000, - hot: true, - stats: { - modules: false, - cached: false, - chunk: false - } + hot: false, + stats: 'errors-only' }, output: { path: root('dist'), filename: '[name].js', - sourceMapFilename: '[name].map', + sourceMapFilename: '[name].[id].map', chunkFilename: '[id].chunk.js' }, module: { + preLoaders: [{ + test: /\.js$/, + loader: 'source-map' + }], loaders: [{ test: /\.ts$/, loaders: [ @@ -89,7 +89,7 @@ module.exports = { }), new webpack.DefinePlugin({ - 'IS_PRODUCTION': false, + 'IS_PRODUCTION': IS_PRODUCTION, 'LIB_VERSION': VERSION }), diff --git a/build/webpack.prod.js b/build/webpack.prod.js index edcaf3b2..96c9b71f 100644 --- a/build/webpack.prod.js +++ b/build/webpack.prod.js @@ -4,6 +4,11 @@ const VERSION = JSON.stringify(require('../package.json').version); const root = require('./helpers').root; const CopyWebpackPlugin = require('copy-webpack-plugin'); +const BANNER = +`ReDoc - OpenAPI/Swagger-generated API Reference Documentation +------------------------------------------------------------- + Version: ${VERSION} + Repo: https://github.com/Rebilly/ReDoc`; module.exports = { context: root(), @@ -72,7 +77,7 @@ module.exports = { }, sourceMap: true }), - + new webpack.BannerPlugin(BANNER), new webpack.DefinePlugin({ 'IS_PRODUCTION': true, 'LIB_VERSION': VERSION diff --git a/package.json b/package.json index 1fe7f22d..78415ec0 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "start": "webpack-dev-server --config build/webpack.dev.js --content-base demo", "e2e-server": "http-server -p 3000 tests/e2e", "e2e-copy": "cp dist/redoc.min.js tests/e2e/", - "webdriver": "webdriver-manager update" + "webdriver": "webdriver-manager update", + "serve:prod": "NODE_ENV=production npm start" }, "keywords": [ "OpenAPI",