Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Configuring Webpack

Ryan Barone
Ryan Barone
7,079 Points

Why do you do "./" before the referencing the app.js file?

At 1:52 in "Setting Up Webpack", "Configuring Webpack" video, you put the following:

module.exports = { entry: './app.js', ... }

Why not just do 'app.js' like <script src="app.js"></script>?

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Ryan Barone,

We do this as Webpack runs in the context of Node, typically the default context when working inside a project folder will be the node_modules folder which isn't great since our code doesn't live there. To overcome this, the majority of developers will prefix paths with ./ which defines the path context to the root of the project folder where your webpack.config.js file lives.

You will see this a lot more as you progress further into ES6 modules which also require the use of ./ to define the root of the project.

Hope that helps.