From c23d9e4aace39ace0c1a06ebbdfcc851fb7cdfce Mon Sep 17 00:00:00 2001 From: Guillaume Briday Date: Sun, 25 Dec 2022 22:36:17 -0500 Subject: [PATCH] Bump to Vite 4 and adding lib name --- vite.config.js | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/vite.config.js b/vite.config.js index 02c1cbb..ec981f3 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,18 +1,26 @@ -const path = require('path') +import { resolve } from 'path' +import { defineConfig } from 'vite' -module.exports = { - build: { - lib: { - entry: path.resolve(__dirname, 'src/index.ts'), - name: 'stimulus-reveal-controller' - }, - rollupOptions: { - external: ['@hotwired/stimulus'], - output: { - globals: { - '@hotwired/stimulus': 'Stimulus' +export default defineConfig(({ mode }) => { + if (mode === 'netlify') { + return {} + } + + return { + build: { + lib: { + entry: resolve(__dirname, 'src/index.ts'), + name: 'StimulusRevealController', + fileName: 'stimulus-reveal-controller' + }, + rollupOptions: { + external: ['@hotwired/stimulus'], + output: { + globals: { + '@hotwired/stimulus': 'Stimulus' + } } } } } -} +})