Code Monkey home page Code Monkey logo

Comments (7)

geoffreydhuyvetters avatar geoffreydhuyvetters commented on June 11, 2024

working on this one, anybody knows of a way to get the webpack.config.js path in a plugin?

from friendly-errors-webpack-plugin.

christophehurpeau avatar christophehurpeau commented on June 11, 2024

There's not always a webpack.config.js, because some create the config via the JS API.

I think the easiest way is to check for path.resolve('yarn.lock'). Another way is to use https://www.npmjs.com/package/pkg-dir and then look for the yarn.lock in to it, based on the pwd. This should work most of the time

from friendly-errors-webpack-plugin.

geoffreydhuyvetters avatar geoffreydhuyvetters commented on June 11, 2024

@christophehurpeau wouldn't both options return the plugin path instead of the folder where webpack is invoked?

from friendly-errors-webpack-plugin.

christophehurpeau avatar christophehurpeau commented on June 11, 2024

path.resolve uses process.cwd(), and process.cwd should return the project path the user is in

from friendly-errors-webpack-plugin.

geoffreydhuyvetters avatar geoffreydhuyvetters commented on June 11, 2024

@christophehurpeau it logs the path to plugin when I run the tests; is it because i ran 'npm test' so process.cwd() is the location where I ran 'npm test' ?

from friendly-errors-webpack-plugin.

christophehurpeau avatar christophehurpeau commented on June 11, 2024

@duivvv yes

from friendly-errors-webpack-plugin.

christophehurpeau avatar christophehurpeau commented on June 11, 2024

maybe you can use https://nodejs.org/api/process.html#process_process_chdir_directory to go to the right test path ?

const previousPwd = process.pwd();
process.chdir(path.dirname(fixture));
try {
  ...
  await webpackPromise(require(fixture), globalPlugins);
  ...
} finally {
  process.chdir(previousPwd);
  ...
}

from friendly-errors-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.