[英]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 ? 为什么路径是绝对的,而不应该像现在这样相对?
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.