Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Change webpack mode config
Browse files Browse the repository at this point in the history
- #11
  • Loading branch information
SoYoung210 committed Nov 2, 2019
1 parent c4988d7 commit 837163d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -4,8 +4,8 @@
"license": "MIT",
"scripts": {
"start": "npm run build:server && npm run build:client && node ./static/server.bundle.js",
"build:server": "webpack --mode=production --config ./webpack.server.js",
"build:client": "webpack --mode=production --config ./webpack.client.js"
"build:server": "webpack --config ./webpack.server.js",
"build:client": "webpack --config ./webpack.client.js"
},
"devDependencies": {
"@babel/core": "7.4.5",
Expand Down
7 changes: 7 additions & 0 deletions webpack.client.js
Expand Up @@ -6,6 +6,11 @@ const CompressionWebpackPlugin = require('compression-webpack-plugin');
const moduleRules = require('./webpack.module');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const hotMiddlewareScript = `webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true`;
const IS_PRODUCTION = process.env.NODE_ENV === 'production'

const getMode = () => (
IS_PRODUCTION ? 'production' : 'development'
)

const getOutputConfig = (name) => ({
filename: '[name].bundle.js',
Expand All @@ -27,6 +32,7 @@ const clientConfig = {
entry: [hotMiddlewareScript,'./client/src/index.tsx'],
target: 'web',
name: 'web',
mode: getMode(),
output: getOutputConfig('web'),
module: {
rules: moduleRules
Expand Down Expand Up @@ -65,6 +71,7 @@ const nodeRenderConfig = {
name: 'node',
entry: [pathResolve( './client/src/routes/index.tsx')],
output: getOutputConfig('node'),
mode: getMode(),
externals: ['@loadable/component', nodeExternals()],
module: {
rules: moduleRules
Expand Down

0 comments on commit 837163d

Please sign in to comment.