2

I have a React project where the root dir has an app directory. Inside the app directory, there is a containers and a components directory. How do I change the following so that webpack actually looks in the directory where my entry point is, for modules.

const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');

const PATHS = {
  app: path.join(__dirname, 'app'),
  build: path.join(__dirname, 'build'),
};

module.exports = {
  // where to start bundling
  entry: [
    './app/app.js',
  ],

  // where to output
  output: {
    // output to same dir
    path: PATHS.build,
    filename: 'timbundle.js',
  },
3
  • I don’t see the relevance of Brainfuck
    – gurghet
    Apr 11, 2017 at 11:23
  • It would seem like your current entry definition should be imported. Do you want to have multiple entry points that exist under containers or components? Apr 11, 2017 at 19:02
  • I think that every file in the modules should be referenced either directly by an app.js import or through a reference from another file. The project is derived from the react-boilerplate repo but I having to build a new webpack config to resolve why some references are not being included.
    – timbo
    Apr 11, 2017 at 20:10

1 Answer 1

2
resolve: {
     modules: ['app', 'node_modules'],
     extensions: ['.js']
},

appears to work.

2
  • Why? Explaination please?
    – pppery
    Apr 12, 2017 at 0:24
  • I'm not entirely sure but it does work. I think that node_modules is the only default. So this specifies the app directory as the root for all modules and you have to add node_modules as you're not using the default anymore. For the record, all my JSX files are just with a .js extension.
    – timbo
    Apr 12, 2017 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.