Last active
June 5, 2019 12:46
-
-
Save lmcarreiro/599695c271576a001bc260f5eef9d9c5 to your computer and use it in GitHub Desktop.
Webpack error with multiple configurations and --info-verbosity verbose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("client"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "test-webpack", | |
"version": "1.0.0", | |
"description": "", | |
"scripts": { | |
"start:ok": "webpack", | |
"start:error": "webpack --info-verbosity verbose" | |
}, | |
"devDependencies": { | |
"@types/node": "^12.0.4", | |
"@types/webpack": "^4.4.32", | |
"webpack": "^4.32.2", | |
"webpack-cli": "^3.3.2" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("server"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @ts-check | |
const webpack = require('webpack'); | |
const path = require('path'); | |
module.exports = [clientConfig, serverConfig]; | |
function clientConfig(env) { | |
/** @type {webpack.Configuration} */ | |
const config = { | |
entry: './index.js', | |
mode: env && env.prod ? 'production' : 'development', | |
target: 'web', | |
output: { | |
path: path.resolve(__dirname, 'build', 'static'), | |
filename: 'index.js', | |
}, | |
resolve: { | |
extensions: ['.js'], | |
}, | |
} | |
return config; | |
} | |
function serverConfig(env) { | |
/** @type {webpack.Configuration} */ | |
const config = { | |
entry: './server.js', | |
mode: env && env.prod ? 'production' : 'development', | |
target: 'node', | |
output: { | |
path: path.resolve(__dirname, 'build'), | |
filename: 'server.js', | |
}, | |
resolve: { | |
extensions: ['.js'], | |
}, | |
} | |
return config; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment