我有两个项目。项目A和项目B.
项目B是项目A的扩展,没有自己的包或依赖项。项目B作为webpack别名包含在项目A中。
const extensions = project.extensions || paths.extensions(); // external directory or internal directory
resolve: {
modules: [
paths.modules(), // absolute path (C:/project/node_modles)
inProject(project.srcDir), // relative path to imported file
'node_modules' // fallback
],
alias: {
extensions: extensions, // mapped from previoues
store: paths.store(), // absolute path alias so Project B can consume
containers: paths.containers(), // absolute path alias so Project B can consume
components: paths.components() // absolute path alias so Project B can consume
}
}
除了巴贝尔以外的一切,这都很好。我似乎缺少的那篇文章是给了babel一个绝对的路径,在哪里找到babel-plugins。它试图从项目B所在的相对node_modules路径而不是从项目A加载它们。
ERROR in ../projectB/file.js
Module build failed: Error: Couldn't find preset "babel-plugin-whatever"
relative to directory "D:\\Users\\tplummer\\projectB"