Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature to using plugin separately #37

Open
alkorlos opened this issue Dec 20, 2023 · 0 comments
Open

Feature to using plugin separately #37

alkorlos opened this issue Dec 20, 2023 · 0 comments

Comments

@alkorlos
Copy link

Vituum have two plugin pages and imports. If you only need one of them now there are a lot of problems with it.

If neen only pages need replace this:

import vituum from 'vituum';

plugins: [
	vituum({
		pages: {
			dir: './templates/pages'
		}
	})
]

To this:

import pages from 'vituum/plugins/pages.js';

plugins: [
	pages({
		dir: './templates/pages'
	})
]

But this is not enough, there will be mistakes
npm run buildCould not resolve entry module "./src/templates/pages/*.html". ...
npm run dev(!) Could not auto-determine entry point from rollupOptions or html files and there are no explicit optimizeDeps.include patterns. Skipping dependency pre-bundling.

issue about this
Need replace this:

rollupOptions: {
	input: ['./src/templates/pages/*.html']
}

to this:

import fg from 'fast-glob'
import { resolve } from 'path'

rollupOptions: {
	input: fg.sync(['./src/templates/pages/*.html']).map(entry => resolve(process.cwd(), entry))
}

Because vite and pages plugin itself doesn't support globs inside rollupOptions.input

After that if necessary nunjucks with only pages plugin:

import pages from 'vituum/plugins/pages.js';

import nunjucks from '@vituum/vite-plugin-nunjucks'

export default {
    build: {
        rollupOptions: {
            input: ['./src/pages/hello.njk'],
        },
    },
    plugins: [
        pages(),
        nunjucks({
            root: './src'
        })
    ],
}

This not work, issue about this

Need replace to:

import pages from 'vituum/plugins/pages.js';

import nunjucks from '@vituum/vite-plugin-nunjucks'

export default {
    build: {
        rollupOptions: {
            input: ['./src/pages/hello.njk.html'],
        },
    },
    plugins: [
        pages(),
        nunjucks({
            root: './src'
        })
    ],
}

It work.

But if replace to:

import pages from 'vituum/plugins/pages.js';

import nunjucks from '@vituum/vite-plugin-nunjucks'

export default {
    build: {
        rollupOptions: {
            input: fg.sync(['./src/templates/pages/*.njk.html']).map(entry => resolve(process.cwd(), entry)),
        },
    },
    plugins: [
        pages(),
        nunjucks({
            root: './src'
        })
    ],
}

Build have error

You must supply options.input to rollup
error during build:
Error: You must supply options.input to rollup

I don`t now what do with it.

Please add feature to use plugin separately with vituum core, many things will become easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant