Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5049

Setting path to ./src in Webpack4?

$
0
0

Just getting started with building my own webpack config. I've looked around but cant seem to find it. How can I set the import path to start at root (src)?

- src
--components
---content
----Content.js
--constants
---example.js
---index.js

If I wanted to import a constant file to my component I'd have to take the ../../constant however I would like to just do ./constants

import { EXAMPLE } from "./constants"

Currently this is my resolve:

  resolve: {
    modules: [path.resolve(__dirname, './src'), 'node_modules'],
    extensions: ['.js'],
  },

But I am getting an error of cant resolve Module not found: Error: Can't resolve './constants'


Viewing all articles
Browse latest Browse all 5049

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>