meatier icon indicating copy to clipboard operation
meatier copied to clipboard

set module directory in babel

Open mattkrick opened this issue 8 years ago • 1 comments

currently some files use relative directories because although webpack knows to look in src, the server doesn't use webpack & gets lost (see ducks, or any other SSR file). To solve this, i can add the module directory to babel on the server & then all paths can be written as absolutes but be relative to src.

untested code example:

resolveModuleSource: function (source, filename) {
    return resolve.sync(source, {
      basedir: path.resolve(filename, ‘..’),
      extensions: [‘.js’],
      moduleDirectory: [
        ‘src’,
        ‘node_modules’,
      ],
    });
  },

mattkrick avatar Apr 23 '16 18:04 mattkrick