0
votes

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?

1

1 Answers

0
votes

Although webpack uses a extended version of nodes require for module resolution, it will not resolve local.js by default. I would assume that if you were to rename local.js to index.js that this would work. Otherwise you could just set the entrypoint to ./index.js or ./index.