Closed phillduffy closed 3 years ago
I have managed to get it working by changing it to the following. Basically, the root and outDir had to change.
const { resolve } = require("path");
import handlebars from "vite-plugin-handlebars";
import { minifyHtml } from "vite-plugin-html";
import viteImagemin from "vite-plugin-imagemin";
import glob from "glob";
import path from "path";
import siteData from "./data";
export default () => {
return {
root: "src",
build: {
outDir: "../dist",
emptyOutDir: true,
rollupOptions: {
input: glob.sync(path.resolve(__dirname, "src", "**/*.html")),
},
},
plugins: [
minifyHtml(),
handlebars({
partialDirectory: resolve(__dirname, "partials"),
context(pagePath) {
return siteData.getPage(pagePath);
},
runtimeOptions: {
data: {
fertilityPages: siteData.fertilityPages,
therapies: siteData.therapies,
},
},
}),
viteImagemin({
verbose: true,
gifsicle: {
optimizationLevel: 3,
interlaced: false,
},
optipng: {
optimizationLevel: 7,
},
webp: {
quality: 75,
},
mozjpeg: {
quality: 65,
},
pngquant: {
quality: [0.65, 0.9],
speed: 4,
},
svgo: {
plugins: [
{
removeViewBox: false,
},
{
removeEmptyAttrs: false,
},
],
},
}),
],
};
};
Can give me a minimal reproduction?
I think this repo is as minimal as I can get
If you change to just the string of "src" and "dist" is works
outDir cannot set an absolute path
root: resolve(__dirname, "./src"),
build: {
outDir: 'dist',
emptyOutDir: true,
},
I am unable to get Imagemin to pick up images in my /src/ directory, it was working before when everything was in root.
vite.config.js
Folder structure