Skip to content

Commit

Permalink
allow for modules options in the webpack plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
eloytoro committed Dec 24, 2016
1 parent a9be241 commit b26e513
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions plugin/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ var path = require("path");
var ResolverFactory = require("enhanced-resolve").ResolverFactory;
var SyncNodeJsInputFileSystem = require("enhanced-resolve/lib/SyncNodeJsInputFileSystem");

function getResolver(configPath) {
function getResolver(modules, configPath) {
var config = {
unsafeCache: true,
modules: ["node_modules"],
modules: modules || ["node_modules"],
extensions: [".js", ".jsx", ".json"],
aliasFields: ["browser"],
mainFields: ["browser", "web", "browserify", "main"],
fileSystem: new SyncNodeJsInputFileSystem()
}
var webpackConfig = fs.existsSync(configPath) ? require(configPath) : null
var webpackConfig = (configPath && fs.existsSync(configPath)) ? require(configPath) : null
if (typeof webpackConfig === 'function') {
webpackConfig = webpackConfig()
}
Expand Down Expand Up @@ -55,8 +55,9 @@ function resolveToFile(resolver, name, parentFile) {

tern.registerPlugin("webpack", function(server, options) {
var configPath = options.configPath || './webpack.config.js'
var modules = options.modules || ['node_modules']
configPath = path.resolve(server.options.projectDir, configPath)
var resolver = getResolver(configPath)
var resolver = getResolver(modules, configPath)
server.loadPlugin("commonjs")
server.loadPlugin("es_modules")
server.mod.modules.resolvers.push(function (name, parentFile) {
Expand Down

0 comments on commit b26e513

Please sign in to comment.