-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
outputDir 和 assetsDir 的配置不能有关联否则会出问题 #2788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
文档里说得很清楚啊,assetsDir 就是相对路径 https://cli.vuejs.org/zh/config/#assetsdir indexPath 可以是相对路径也可以是绝对路径并且不会干扰到其他设置,所以这样就可以放心地把 index.html 移动到其他目录了。outputDir + assetsDir 就是为了输出静态资源用的。 |
assetsDir 有一个功能是告诉index.html 你打包后的(css、js、img)存放在哪里 我认为打包后输出静态文件的目录是outputDir 注意看一下我事例最后index.html 输出的打包后的<scripts src=assetsDir+/js/app.23e82727.js文件 前面是不是取的是assetsDir这个值 |
@sodatea 你的文档可能没理解对这个assetsDir的作用 看上面引用回复 |
我是从实现层面理解的。 outputDir 就是 webpack 中的 output.path,assetsDir 是用来生成各种 filename 时用到的 subpath,所以最后反映出来的输出目录就是它们拼接到一起。 我还是不理解你这个 Bug Report 指的具体 bug 是什么?我们的文档和行为有什么不一致的地方吗? |
@sodatea 那请问一下 index.html 里面自动填写的打包后的结果<scripts src=assetsDir+/js/app.23e82727.js 而且我的这个例子在我还没用cli3得时候就可以达到得效果 现在反而不行了是为什么?是一种进步的实现还是考虑的不够详细? |
@sodatea 如果你说这样配置 这个outputDir是不是清空了app目录下的文件 这样会导致我服务端的文件被清空 要解决这个 |
有一个暂时的 workaround 是打包时加上 |
@sodatea 3Q |
|
这里的问题根源是 egg.js 对于
|
@yyx990803 但是还没到cli 3的时候这两个配置一直都是分开的 如果并在一起反而不够便利 如果能灵活处理为啥一定要绑死? |
Version
3.0.5
Node and OS info
Windows 10 node v8.9.3
Steps to reproduce
outputDir 和 assetsDir 同时配置 后
npm run build 的时候会打包的文件不是只指向outputDir 的目录 而是 outputDir + assetsDir 的目录
而这样已关联assetsDir配置会找不到文件
------------------------------- 具体事例 ------------------------------------------------------------------
配置如下:
{
outputDir: path.resolve(__dirname, '..', 'app/public/build'),
assetsDir: 'public/build',
indexPath: path.resolve(__dirname, '..', 'app/view/index.html'),
}
我的项目是eggjs项目
项目默认的静态文件位置位于app/public
项目读取index.html的目录是 app/view
于是我outputDir配置到 app/public/build下
assetsDir由于项目原因必须 public 开头 所以配置为 public/build
build结果:生成css、js、img的目录变成了 app/public/public/build/(css、js、img)
<script src=/public/build/js/app.23e82727.js></script>然而 index.html 里面针对打包后的 css、js、img 都是 /public/build/(css、js、img)
What is expected?
outputDir 和 assetsDir 本来就应该独立配置
不应该有 outputDir + assetsDir 的相关输出配置
What is actually happening?
outputDir 和 assetsDir 同时配置 后
npm run build 的时候会打包的文件不是只指向outputDir 的目录 而是 outputDir + assetsDir 的目录
The text was updated successfully, but these errors were encountered: