From 79693e1b276225be256b5e5ea0db849f31c7b3a6 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 28 Sep 2016 00:30:33 +0300 Subject: [PATCH] Fix npm start on windows, fixes #119, #118 --- build/webpack.dev.js | 11 ++++++----- build/webpack.prod.js | 6 ++++-- build/webpack.test.js | 19 ++++++++++--------- lib/index.ts | 8 +++++++- manual-types/index.d.ts | 1 + 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/build/webpack.dev.js b/build/webpack.dev.js index c48af3f3..ff2ddacc 100644 --- a/build/webpack.dev.js +++ b/build/webpack.dev.js @@ -13,7 +13,6 @@ module.exports = { resolve: { extensions: ['.ts', '.js', '.json', '.css'], alias: { - './lib/bootstrap': root('lib/bootstrap.dev'), http: 'stream-http', https: 'stream-http' } @@ -55,7 +54,8 @@ module.exports = { }, module: { - loaders: [{ + exprContextCritical: false, + rules: [{ enforce: 'pre', test: /\.js$/, loader: 'source-map-loader', @@ -70,13 +70,13 @@ module.exports = { ], exclude: [/\.(spec|e2e)\.ts$/] }, { - test: /lib\/.*\.css$/, + test: /lib[\\\/].*\.css$/, loaders: ['raw-loader'], exclude: [/redoc-initial-styles\.css$/] }, { test: /\.css$/, loaders: ['style', 'css?-import'], - exclude: [/lib\/(?!.*redoc-initial-styles).*\.css$/] + exclude: [/lib[\\\/](?!.*redoc-initial-styles).*\.css$/] }, { test: /\.html$/, loader: 'raw-loader' @@ -93,7 +93,8 @@ module.exports = { new webpack.DefinePlugin({ 'IS_PRODUCTION': IS_PRODUCTION, - 'LIB_VERSION': VERSION + 'LIB_VERSION': VERSION, + 'AOT': IS_PRODUCTION }), new ForkCheckerPlugin() diff --git a/build/webpack.prod.js b/build/webpack.prod.js index 0ccfa7ab..ae10a82e 100644 --- a/build/webpack.prod.js +++ b/build/webpack.prod.js @@ -48,7 +48,8 @@ module.exports = { }, module: { - loaders: [{ + exprContextCritical: false, + rules: [{ enforce: 'pre', test: /\.js$/, loader: 'source-map-loader', @@ -84,7 +85,8 @@ module.exports = { new webpack.BannerPlugin(BANNER), new webpack.DefinePlugin({ 'IS_PRODUCTION': true, - 'LIB_VERSION': VERSION + 'LIB_VERSION': VERSION, + 'AOT': true }) ], } diff --git a/build/webpack.test.js b/build/webpack.test.js index 9aa2cde9..869faf91 100644 --- a/build/webpack.test.js +++ b/build/webpack.test.js @@ -10,7 +10,6 @@ module.exports = { resolve: { extensions: ['.ts', '.js', '.json', '.css'], alias: { - './lib/bootstrap': root('lib/bootstrap.dev'), http: 'stream-http', https: 'stream-http' } @@ -37,6 +36,7 @@ module.exports = { }, module: { + exprContextCritical: false, rules: [{ enforce: 'pre', test: /\.js$/, @@ -56,13 +56,13 @@ module.exports = { ], exclude: [/\.(spec|e2e)\.ts$/] }, { - test: /lib\/.*\.css$/, + test: /lib[\\\/].*\.css$/, loaders: ['raw-loader'], exclude: [/redoc-initial-styles\.css$/] }, { test: /\.css$/, loaders: ['style', 'css?-import'], - exclude: [/lib\/(?!.*redoc-initial-styles).*\.css$/] + exclude: [/lib[\\\/](?!.*redoc-initial-styles).*\.css$/] }, { test: /\.html$/, loader: 'raw-loader' @@ -86,7 +86,8 @@ module.exports = { plugins: [ new webpack.DefinePlugin({ 'IS_PRODUCTION': false, - 'LIB_VERSION': VERSION + 'LIB_VERSION': VERSION, + 'AOT': 'false' }), new webpack.LoaderOptionsPlugin({ test: /\.ts$/, @@ -97,11 +98,11 @@ module.exports = { }), // ignore changes during tests new webpack.WatchIgnorePlugin([ - /\/ReDoc$/i, // ignore change of ReDoc folder itself - /node_modules\/(?:[^\/]*(?:\/|$))*[^\/]*$/, - /\.tmp\/(?:[^\/]*(?:\/|$))*[^\/]*$/, - /dist\/(?:[^\/]*(?:\/|$))*[^\/]*$/, - /(?:[^\/]*(?:\/|$))*[^\/]*\.css$/ // ignore css files + /[\\\/]ReDoc$/i, // ignore change of ReDoc folder itself + /node_modules[\\\/].*$/, + /\.tmp[\\\/].*$/, + /dist[\\\/].*$/, + /(?:[^\\\/]*(?:[\\\/]|$))*[^\\\/]*\.css$/ // ignore css files ]) ], } diff --git a/lib/index.ts b/lib/index.ts index 06eeef8a..1ad46f3a 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -6,7 +6,13 @@ import { Redoc } from './components/index'; import { SpecManager } from './utils/SpecManager'; import { BrowserDomAdapter as DOM } from './utils/browser-adapter'; import { disableDebugTools } from '@angular/platform-browser'; -import { bootstrapRedoc } from './bootstrap'; + +var bootstrapRedoc; +if (AOT) { + bootstrapRedoc = require('./bootstrap').bootstrapRedoc; +} else { + bootstrapRedoc = require('./bootstrap.dev').bootstrapRedoc; +} if (IS_PRODUCTION) { disableDebugTools(); diff --git a/manual-types/index.d.ts b/manual-types/index.d.ts index 22733ca1..faecbd1c 100644 --- a/manual-types/index.d.ts +++ b/manual-types/index.d.ts @@ -14,6 +14,7 @@ declare module "*.css" { declare var LIB_VERSION: any; declare var IS_PRODUCTION: any; +declare var AOT: any; interface ErrorStackTraceLimit { stackTraceLimit: number;