diff --git a/docs/development.md b/docs/development.md index 699db7674c8..0c1fc31046d 100644 --- a/docs/development.md +++ b/docs/development.md @@ -23,6 +23,14 @@ opening the browser DO_NOT_OPEN=true npm start ``` +### Running in production mode + +Pass `--production` flag to `npm start` to run in production mode +```shell +npm start --production + +``` + ### Building To build the project for production use, run: diff --git a/package.json b/package.json index 9a0d2d099a0..323736757fd 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ }, "devDependencies": { "angular": "^1.5.2", + "angular-cookies": "^1.5.5", "angular-json-schema-form": "^0.1.4", "angular-marked": "^1.0.1", "angular-mocks": "^1.5.2", diff --git a/scripts/router.js b/scripts/router.js index 47c1077e648..ea4909c8715 100644 --- a/scripts/router.js +++ b/scripts/router.js @@ -1,5 +1,7 @@ 'use strict'; +var angular = require('angular'); + SwaggerEditor.config(function Router($compileProvider, $stateProvider, $urlRouterProvider, $logProvider) { $urlRouterProvider.otherwise('/'); @@ -27,8 +29,11 @@ SwaggerEditor.config(function Router($compileProvider, $stateProvider, } }); + var $cookies = angular.injector([require('angular-cookies')]).get('$cookies'); + var isDevelopment = Boolean($cookies.get('swagger-editor-development-mode')); + $compileProvider.aHrefSanitizationWhitelist('.'); - $compileProvider.debugInfoEnabled(true); - $logProvider.debugEnabled(true); + $compileProvider.debugInfoEnabled(isDevelopment); + $logProvider.debugEnabled(isDevelopment); }); diff --git a/server.js b/server.js index a6e8fcf0b56..723f1a58c55 100644 --- a/server.js +++ b/server.js @@ -5,6 +5,7 @@ var WebpackDevServer = require('webpack-dev-server'); var config = require('./webpack.config'); var open = require('open'); var IP = '127.0.0.1'; +var argv = require('minimist')(process.argv.slice(2)); /** * Start the server with webpack config @@ -20,7 +21,11 @@ function startServer(port, cb) { var server = new WebpackDevServer(compiler, { progress: true, quiet: true, - publicPath: config.output.publicPath + publicPath: config.output.publicPath, + headers: { + 'Set-Cookie': + 'swagger-editor-development-mode:' + Boolean(argv.production) + ';' + } }); server.listen(port, IP, cb);