Giter VIP home page Giter VIP logo

Comments (5)

sanmai-NL avatar sanmai-NL commented on August 28, 2024 1

.vite.config.js:

import { defineConfig } from 'vite';
import { readFileSync } from 'fs';
import vitePugPlugin from 'vite-plugin-pug-transformer';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import fastglob from 'fast-glob';

const _dirname = typeof __dirname !== 'undefined' ? __dirname : dirname(fileURLToPath(import.meta.url));
const optionsHttps = {
  key: readFileSync('localhost-key.pem'),
  cert: readFileSync('localhost.pem'),
};

export default defineConfig({
  base: '/mads/materials/',
  build: {
    rollupOptions: {
      input: fastglob.sync(['index.html', 'public/**/*.html'], { dot: true }).map(entry => resolve(_dirname, entry)),
    },
    target: 'es2020',
  },
  optimizeDeps: { esbuildOptions: { target: 'es2020' } },
  plugins: [vitePugPlugin()],
  server: { https: optionsHttps },
});

from vite-plugin-pug-transformer.

sanmai-NL avatar sanmai-NL commented on August 28, 2024 1

Thanks, you're right. It works with:

.vite.config.js:

import { defineConfig } from 'vite';
import { readFileSync } from 'fs';
import vitePugPlugin from 'vite-plugin-pug-transformer';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import fastglob from 'fast-glob';

const _dirname = typeof __dirname !== 'undefined' ? __dirname : dirname(fileURLToPath(import.meta.url));
const dirnameTemplates = resolve(_dirname, 'templates');
const optionsHttps = {
  key: readFileSync('localhost-key.pem'),
  cert: readFileSync('localhost.pem'),
};
const pages = fastglob.sync(['**/*.html'], {
  absolute: true,
  cwd: dirnameTemplates,
  dot: true,
  throwErrorOnBrokenSymbolicLink: true,
});

export default defineConfig({
  base: '/mads/materials/',
  build: {
    emptyOutDir: true,
    outDir: '../dist',
    rollupOptions: {
      input: pages,
    },
    target: 'es2020',
  },
  optimizeDeps: { esbuildOptions: { target: 'es2020' } },
  plugins: [vitePugPlugin()],
  root: dirnameTemplates,
  server: { https: optionsHttps },
});

from vite-plugin-pug-transformer.

TheSeally avatar TheSeally commented on August 28, 2024

Hello, thanks for reporting problem.
I will look this as soon as possible

from vite-plugin-pug-transformer.

TheSeally avatar TheSeally commented on August 28, 2024

@sanmai-NL , I try to reproduce this issue, but in my case plugin works for all page specified in the vite configuration.

Can you share your vite configuration or maybe even sandbox where the problem is reproduced?

from vite-plugin-pug-transformer.

TheSeally avatar TheSeally commented on August 28, 2024

I think this is the specific of vite.
According to the documentation public directory is copied as-is without any transformation

So, you need to rename the directory, or change this behaviour in vite config

from vite-plugin-pug-transformer.

Related Issues (5)

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.