Git Product home page Git Product logo

astro-parcel's Introduction

astro-parcel

Build and optimize your Astro project using Parcel

Install

npm i --save-dev astro-parcel

CLI

astro-parcel <command> [options]
Build and optimize your astro project using Parcel

Commands
build
dev
serve

Options
--astroDist <string = "./dist">     the directory that astro writes the build result to
--parcelDist <string = "./dist">    the directory to output the parcel result
--publicDir <string = "./public">   the public folder path. The files that are directly copied to parcelDist folder
--srcDir <string = "./src">         the src folder. This path is used to search for the files that are not present in astroDist folder

Extra arguments are directly passed to Astro and then Parcel

Advanced Options
--astroJs <string = resolved>       the astro cli js path
--parcelJs <string = resolved>      the parcel cli js path
--nodeBin  <string = current node>  the node bin path

To use astro-parcel, you should configure your Astro project like normal. Then, call the astro-parcel commands.

To build the project:

astro-parcel build

You can also specify the build directory for Parcel via --parcelDist. If you have changed the outDir of Astro, you should pass it here as --astroDist:

astro-parcel build --astroDist "./dist" --parcelDist "./parcel-dist"

To use another version of Astrojs or Parceljs pass their binary js paths via --astroJs and --parcelJs.

astro-parcel build --astroDist "./dist" --parcelDist "./parcel-dist" --parcelJs "./node_modules/parcel/lib/bin.js" --astroJs "./node_modules/astro/dist/cli/index.js"

Why

Astro is a great framework for making websites, and Parcel provides awesome bundling and optimization (e.g. Parcel-CSS, HTMLNano, etc.) functionality out of the box. This package makes it possible to use Astro with Parcel.

Using Parcel as the CSS, LESS, SCSS Bundler

Astro's CSS bundling can result in duplicate files, while Parcel's CSS functionality is great in optimizing the CSS files. To use that, link the style files like the following. Use a unique file name, so astro-parcel can resolve it in the source directory. The await import is used for the dev build, and the <link> tag is used by for the production build.

---
if (process.env.NODE_ENV !== "production") {
  await import("./style.scss")
}
---

<head>
  <link rel="stylesheet" href="./styles.scss" class="href">
</head>

To use a single CSS bundle for the whole website, create a ./pages/styles.scss and import all the CSS files used in your Page, and link it to your HTML files under the pages folder.

@use "../components/navbar/navbar.scss";
@use "../components/footer/footer.scss";

astro-parcel's People

Contributors

aminya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

astro-parcel's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.