.net-core - 带有 dotnet 核心的 Parceljs

标签 .net-core bundler parceljs

我想尝试用parceljs来缩小和 bundle 。

我已经使用 npm 安装了 Parcel-bundler,并尝试创建一个 index.js、main.js 和 main.css 进行测试。

ma​​in.css

.main
{
    color: red;
}

ma​​in.js

import classes from './main.css';

export default () => {
    console.log(classes);
};

index.js

import main from './main';

main();

在我的layout.cshtml 文件中,我包含了index.js 文件,但这就是我陷入困境的地方。 我知道我可以从 powershell\cmd 运行 Parcel,它说服务器正在端口 1234 上运行。但是,我想使用 dotnet run。

当像平常一样运行 dotnet run 时,我从 index.js 文件中得到“意外的 token ”。我猜想启动 dotnet run 时 Parcel 不会运行。

最佳答案

我也遇到同样的问题。如果您只想在没有服务器的情况下运行 Parcel,您可以执行 parcel watch index.js 但您必须使其与 dotnet 同时运行才能获得 Hot模块重新加载。我们真正需要的是相当于 WebpackDevMiddleware 的 Parcel。

另一种选择是使用类似 Concurrently 的内容。同时运行这两个命令。然后您可以像这样设置 NPM 脚本:

"scripts": {
    "dev": "concurrently \"dotnet run\" \"parcel watch index.js\""
}

然后运行:

npm run dev

关于.net-core - 带有 dotnet 核心的 Parceljs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48260519/

相关文章:

ruby-on-rails - 使用 $ sudo bundle exec ... 引发 'bundle: command not found' 错误

ruby-on-rails - 从 Gemfile 中删除 gem 后要做什么?

javascript - 为什么我的 .vue 组件未定义?

javascript - parcel serve 为 SourceMap 请求和不存在的 url 返回 index.html

node.js - Parceljs 捆绑问题

c# - 升级到 inProcess 后,我在双斜杠上得到了 404

.Net Core - 构建发布不会复制 NUGET 依赖项

asp.net-core - 当我在浏览器中刷新页面时,如何在 ASP.NET Core 2.2 中启用自动重建?

asp.net-core - 如何添加 Content-Type : application/octet-stream to .Net Core header

ruby-on-rails - Rails 寻找错误的 bundler 路径