Code Monkey home page Code Monkey logo

astro-deno-template's Introduction

Astro Deno Template

First things first, you don't have to use this template.

First, install Deno 1.35 or later https://deno.com/

Then run:

deno run -A npm:create-astro --no-install astro-deno
cd astro-deno
deno task dev

Open http://localhost:3000

Let's explain what just happened.

First is that we are not using Node, because Deno has npm compatibility built in.

So when running npm:create-astro we are initializing our project using Deno. That's why we don't want to run npm install and passed --no-install flag. The parameter astro-deno could be omitted if you want to change the name of the project.

And now deno task dev will search for dev script in package.json and run it using Deno, you can also just run deno run -A npm:astro dev which is going to be exactly the same.

You can also use deno task build && deno task preview to build and preview your project because by default it's going to generate a static website.

Why do you need this template then?

Well, again, you don't need it. For the most part, you can use standard Astro documentation, but use stuff like deno run -A npm:astro add instead of npx astro add and so on. There are some tricky parts, like dependency management if you want to use npm dependencies, or typescript issues if you want to use Deno APIs. So if you rely on some Deno stuff, like Deno.KV you would only be able to deploy your project to Deno Deploy (obviously). But keep in mind that because bundling happens in Vite, Vite doesn't understand how to use URL imports, so you won't be easily able to use Deno dependancies in your project.

What is not working in Astro

This is not a complete list, just a few things that I've noticed:

  • deno run -A npm:astro check doesn't work
  • Tailwind and PostCSS in general

How to use this template

Create project:

# be prepared to wait and press enter a few times
deno run -A npm:create-astro --template JLarky/astro-deno-template --no-install astro-deno
cd astro-deno

For the most part, this is going to be the same as the regular template, but here are the differences:

  • you get deno.jsonc file with tasks for dev, build and preview so that you don't have to look at that warning anymore Warning Currently only basic package.json scripts are supported. Programs like rimraf or cross-env will not work correctly. This will be fixed in an upcoming release.
  • deno-deploy adapter is already configured in astro.config.mjs

Dev:

deno task dev
# open http://localhost:3000

Build & preview:

deno task build
deno task preview
# open http://localhost:8085

Deploy:

You have to use deployctl (https://github.com/denoland/deployctl) because Astro requires a build step, you can either do that locally after deno task build or you can use GitHub Actions to do that for you.

See also

astro-deno-template's People

Contributors

astrobot-houston avatar jlarky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

astro-deno-template's Issues

Have you tried Astro with Deno 1.35?

@JLarky thanks for putting together this template. In Deno's 1.35 announcement post, they said they now support npm:astro -- have you tried it and would it change anything in your template?

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.