简体   繁体   English

Angular CLI 1.6.6弹出带有完整脚本路径的create webpack.config.js

[英]Angular CLI 1.6.6 eject create webpack.config.js with full scripts path

I just have installed the newest version of angular (5.2.0) and CLI 1.6.6. 我刚刚安装了angular(5.2.0)和CLI 1.6.6的最新版本。 I did eject command and get webpack.config.js with full scripts path: 我确实弹出命令并获取具有完整脚本路径的webpack.config.js:

"plugins": [
    new NoEmitOnErrorsPlugin(),
    new ScriptsWebpackPlugin({
      "name": "scripts",
      "sourceMap": true,
      "filename": "scripts.bundle.js",
      "scripts": [
        "D:\\GitProjects\\Product\\ProjectName\\node_modules\\jquery\\dist\\jquery.min.js",
        "D:\\GitProjects\\Product\\ProjectName\\node_modules\\tv4\\tv4.js"
      ],
      "basePath": "D:\\GitProjects\\Product\\ProjectName"
    }),

Why does paths are absolute, should not be relative as it was until now ? 为什么路径是绝对的,而不应该像现在这样相对?

It is a known bug . 这是一个已知的错误 Well, since "eject" is a one-time use command, the best thing you can do is changing the paths manually (or write a simple script for it). 好吧,由于“弹出”是一次性使用命令,因此您可以做的最好的事情是手动更改路径(或为其编写一个简单的脚本)。

Solution is to replace all absolute paths with relative. 解决方案是将所有绝对路径替换为相对路径。 We can use process.cwd() for that. 我们可以使用process.cwd()。 process.cwd() returns the current working directory process.cwd()返回当前工作目录

"plugins": [
    new NoEmitOnErrorsPlugin(),
    new ScriptsWebpackPlugin({
      "name": "scripts",
      "sourceMap": true,
      "filename": "scripts.bundle.js",
      "scripts": [
        path.join(process.cwd(), "node_modules\\jquery\\dist\\jquery.min.js");,
        path.join(process.cwd(), "node_modules\\tv4\\tv4.js");
      ],
      "basePath": process.cwd()
    }),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM