diff --git a/package.json b/package.json index cc9f5c5..18bd157 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "scripts": { "client": "webpack-dev-server --hot --config webpack.client.config.js", "server": "DEBUG=@avocado:* webpack --autorun --watch --hot --config webpack.server.config.js", + "client:build": "webpack --config webpack.client.config.js", "server:build": "webpack --config webpack.server.config.js", "start": "webpack --config webpack.server.config.js && webpack-dev-server --config webpack.client.config.js" }, diff --git a/webpack.client.config.js b/webpack.client.config.js index 006ec2e..525a9a3 100644 --- a/webpack.client.config.js +++ b/webpack.client.config.js @@ -4,6 +4,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); const webpack = require('webpack'); const config = require('./webpack.common.config'); +const isProduction = !!process.argv.find((arg) => '--production' === arg); config.entry = { client: [ @@ -16,28 +17,33 @@ config.entry = { path.join(__dirname, 'client', 'index.js'), ], }; -config.devServer = { - compress: true, - contentBase: path.resolve(__dirname, 'resource'), - disableHostCheck: true, - headers: { - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS', - 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization', - }, - host: '0.0.0.0', - overlay: true, - port: 8421, - proxy: { - '/avocado': { - target: 'http://localhost:8420', - ws: true, +if (!isProduction) { + config.devServer = { + compress: true, + contentBase: path.resolve(__dirname, 'resource'), + disableHostCheck: true, + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS', + 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization', }, - }, - stats: 'minimal', - watchContentBase: true, -}; -config.devtool = 'eval-source-map'; + host: '0.0.0.0', + overlay: true, + port: 8421, + // proxy: { + // '/avocado': { + // target: 'http://localhost:8420', + // ws: true, + // }, + // }, + stats: 'minimal', + watchContentBase: true, + }; + config.devtool = 'eval-source-map'; +} +else { + config.devtool = 'source-map'; +} // Babel config file. config.module.rules[0].use.options.configFile = path.resolve( __dirname, 'babel.client.config.js' diff --git a/webpack.server.config.js b/webpack.server.config.js index f84fbcc..518bb1a 100644 --- a/webpack.server.config.js +++ b/webpack.server.config.js @@ -5,8 +5,11 @@ const nodeExternals = require('webpack-node-externals'); const StartServerPlugin = require('start-server-webpack-plugin'); const config = require('./webpack.common.config'); +const isProduction = !!process.argv.find((arg) => '--production' === arg); -config.devtool = 'source-map'; +if (!isProduction) { + config.devtool = 'source-map'; +} config.entry = { server: [ 'source-map-support/register',