Reputation: 95
There is a file in /path/to/src/index.js
.
In webpack1 I can use "import '/path/to/src'"
to load the index.js
, but it does not work in webpack2, notices that "module not found"
.
So how to config webpack2 to auto load index.js
file?
Upvotes: 1
Views: 825
Reputation: 1
module.exports = {
resolve: {
extensions: [
'/index.js', '/index.vue', '/index.json',
'.js', '.vue', '.json'
],
alias: {
'@': resolve('src')
}
}
}
I fixed the problem with this config. But that's weird.
Upvotes: 0
Reputation: 627
I had the same trouble. I fixed it by adding this to the webpack config:
resolve: {extensions: ["*", ".js"]},
If you need to expand this or customize it to your config then there's more information on Webpack's site: https://webpack.js.org/configuration/resolve/
Upvotes: 2