Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,662 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.