ternjs / tern

A JavaScript code analyzer for deep, cross-editor language support
https://ternjs.net/
MIT License
4.25k stars 378 forks source link

Document webpack plugin #858

Open JelteF opened 7 years ago

JelteF commented 7 years ago

I see that there is a webpack plugin, which I would like to use. But I, can't figure out how to configure it correctly. My own module root is in static/js/modules/ how do I use the files there for path resolving?

chemzqm commented 7 years ago

I will add the document of webpack plugin and add support to webpack2 in my next PR.

You can add something like:

  "plugins": {
    "webpack": {
      "configPath": "./static/js/modules/webpack.config.js"
    }
  }

to your .tern-project file.

JelteF commented 7 years ago

Thanks for the help, but I don't have a webpack.config.js file because I'm running webpack using gulp. What should I put in the file then?

Just to be sure, my directory tree looks like this:

./gulpfile.js
<other files and directories>
./static/js/modules
./node_modules

And node_modules contains the deps, but static/js/modules contains my own js code.

And this is in my gulpfile:

{
  context: __dirname + '/static/js',
  resolve: {
    root: [
      __dirname + '/static/js/modules',
      __dirname + '/static/css',
      __dirname + '/static/templates',
    ],

    extensions: ['', '.js', '.jsx'],
  },
  // ... other config stuff that doesn't seem important
}
chemzqm commented 7 years ago

@JelteF I suggest create a webpack.config.js which export webpack config, and make your gulpfile.js require webpack.config.js.

The file webpack.config.js could be long and specified to work on different environment, it would harder for maintain if it exist in other file.