I have a subdirectory subdir with this file:
// subdir/local.js
document.body.textContent = 'hello from subdir/local.js'
and local webpack.config.js:
// subdir/webpack.config.js
const {
createConfig,
entryPoint,
setOutput } = require('@webpack-blocks/webpack')
const devServer = require('@webpack-blocks/dev-server')
module.exports = createConfig([
entryPoint('.'),
setOutput('./bundle.js'),
devServer(),
])
The same config works in the root directory. However, running locally
webpack local.js
leads to the error:
ERROR in multi main Module not found: Error: Cannot resolve 'file' or 'directory' . in /Users/dmitrizaitsev/Dropbox/Sandbox/webpack-blocks-test/subdir @ multi main
How can I fix that error and run webpack with projects in subdirectories?
Although webpack uses a extended version of nodes
requirefor module resolution, it will not resolvelocal.jsby default. I would assume that if you were to rename local.js toindex.jsthat this would work. Otherwise you could just set the entrypoint to./index.jsor./index.