2

I want to try parceljs for minifying and bundling.

I have installed the parcel-bundler with npm, and i tried creating a index.js, main.js and main.css for testing.

main.css

.main
{
    color: red;
}

main.js

import classes from './main.css';

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

index.js

import main from './main';

main();

In my layout.cshtml file i have included the index.js file, but this is where im stuck. I know that i can run parcel from powershell\cmd, and it says the server is running on port 1234. However, i want to use dotnet run.

When running dotnet run like i normally do i get "Unexpected token" from the index.js file. I guess parcel does not run when starting dotnet run.

sindrem
  • 1,211
  • 5
  • 24
  • 45

1 Answers1

3

I'm having the same problem. If you just want to run Parcel without the server you can do parcel watch index.js but you'll have to have this running at the same time as dotnet to get Hot Module Reloading. What we really need is the Parcel equivalent of WebpackDevMiddleware.

Another option is to use something like Concurrently to run both commands at the same time. You could then setup an NPM script like this:

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

and run:

npm run dev
blues_driven
  • 331
  • 2
  • 7