【问题标题】:Can I specify the output folder for assets?我可以指定资产的输出文件夹吗?
【发布时间】:2019-01-10 12:33:04
【问题描述】:

我有一个具有这种结构的项目:

src
 |- index.pug
 | - layout
 |     |- index.less
 | - scripts
 |     |- index.js

现在,当我运行 parcel build src/index.pug 时,所有文件都被捆绑在一起,我在分发文件夹中找到了这个:

dist
  |- index.html
  |- index.12345.css
  |- index.12345.js

当我被监视时:

dist
  |- index.html
  |- layout
  |    |- index.12345.css
  |- scripts
  |    |- index.12345.js

所以,我的问题是:我可以使用 ParcelJS 指定我的 css、js 和图像的输出路径吗?

【问题讨论】:

标签: parceljs


【解决方案1】:

Parcel 不支持开箱即用的此功能,但我为它开发了一个插件。看看https://www.npmjs.com/package/parcel-plugin-custom-dist-structure

它适用于所有类型的 web/node 开发项目,它会生成您指定的 dist 结构,同时还可以处理您的导入。

让我知道你的想法!

【讨论】:

  • 在更改引用图像的文件时遇到了一些问题,但是一旦我重新启动 npx parcel serve index.html,它就可以正常工作了。如果问题变得更大,我会看看我是否可以一致地重现它并提交问题。
  • 一个非常好的插件,但不幸的是它不会改变对 html 中 css 的引用(虽然适用于脚本):github.com/VladimirMikulic/parcel-plugin-custom-dist-structure/…
  • 这是一个很酷的插件,但 parcel 1 已被弃用,遗憾的是,此插件目前不支持 parcel 2。
  • @EricXinZhang 你的问题已经解决了:)
  • @RomanStarkov 感谢您的关注。几天前,我将我的两个 Parcel 插件迁移到了版本 2,希望我也能尽快迁移 parcel-plugin-custom-dist-structure。
【解决方案2】:

不支持版本 1。这应该通过用户插件在版本 2 中可用。见https://github.com/parcel-bundler/parcel/issues/233

【讨论】:

    猜你喜欢
    • 2012-03-10
    • 1970-01-01
    • 2014-06-22
    • 1970-01-01
    • 2012-05-21
    • 2023-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多