Answer the question
In order to leave comments, you need to log in
How to import webpack config?
Why module.exports
does webpack work correctly when I use it.
const path = require('path')
const config = {
entry:{
main:'./src/index.js'
},
output: {
filename: '[name].[contenthash].js',
path: path.resolve(__dirname, 'dist')
}
}
module.exports = config
export/import
in node.jsimport path from 'path'
const config = {
entry:{
main:'./src/index.js'
},
output: {
filename: '[name].[contenthash].js',
path: path.resolve(__dirname, 'dist')
}
}
export config
[webpack-cli] Failed to load 'C:\Users\denis\Desktop\ASP\webpack.config.js' config
[webpack-cli] TypeError: Invalid host defined options
at eval (eval at dynamicImportLoader (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\lib\utils\dynamic-import-loader.js:5:21), <anonymous>:3:1)
at loadConfig (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\lib\webpack-cli.js:1346:41)
at WebpackCLI.resolveConfig (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\lib\webpack-cli.js:1454:44)
at WebpackCLI.createCompiler (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\lib\webpack-cli.js:1839:33)
at WebpackCLI.buildCommand (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\lib\webpack-cli.js:1954:31)
at Command.<anonymous> (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\lib\webpack-cli.js:735:36)
at Command.listener [as _actionHandler] (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\node_modules\commander\index.js:922:31)
at Command._parseCommand (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\node_modules\commander\index.js:1503:14)
at Command._dispatchSubcommand (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\node_modules\commander\index.js:1443:18)
at Command._parseCommand (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\node_modules\commander\index.js:1460:12)
package.json
I put "type": "module" but still doesn't work
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question