Permalink
Browse files

allow for `modules` options in the webpack plugin

  • Loading branch information...
1 parent a9be241 commit b26e513f7bb8c7bb3509b7ce7066212673cef285 @eloytoro eloytoro committed Dec 24, 2016
Showing with 5 additions and 4 deletions.
  1. +5 −4 plugin/webpack.js
View
@@ -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()
}
@@ -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) {

0 comments on commit b26e513

Please sign in to comment.