Skip to content
Discussion options

You must be logged in to vote

Hi @bkwdesign,

do you mean how to include TypeScript file in Pug template so that it is compiled in native JS?

I recommend using the pug-plugin, not pug-loader.

In Pug template you can directly define source script (e.g. TypeScript) and source style (e.g. Sass, SCSS, Less, etc.) files:

html
  head
    link(href=require('./styles.scss') rel='stylesheet')
    script(src=require('./main.ts'))
  body
   h1 Hello Pug!

The TS file loaded via require('./main.ts') will be compiled via Webpack into JS with hashed filename:

<html>
  <head>
    <link href="/assets/css/styles.05e4dd86.css" rel="stylesheet">
    <script src="/assets/js/main.f4b855d8.js"></script>
  </head>
  <body>
    <h1>Hello Pug!</h1

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by bkwdesign
Comment options

You must be logged in to vote
1 reply
@webdiscus
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants