Last active
July 10, 2022 16:58
-
-
Save hrsetyono/4c26804b9ff7fc895878d60296fe884e to your computer and use it in GitHub Desktop.
Vite for WordPress (work in progress, hot reload not yet working)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "my-app", | |
"private": true, | |
"repository": { | |
"type": "git", | |
"url": "git+https://github.com/username/my-app" | |
}, | |
"dependencies": {}, | |
"devDependencies": { | |
"sass": "^1.53.0", | |
"vite": "^2.9.9", | |
"eslint": "^7.32.0", | |
"eslint-config-airbnb-base": "^14.2.1", | |
"eslint-plugin-import": "^2.24.2" | |
}, | |
"scripts": { | |
"dev": "vite", | |
"build": "vite build" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { defineConfig } from 'vite'; | |
export default defineConfig({ | |
base: '', | |
build: { | |
outDir: 'dist', | |
assetsDir: '', | |
rollupOptions: { | |
input: { | |
app: './assets/js/app.js', | |
}, | |
output: { | |
entryFileNames: '[name].js', | |
chunkFileNames: '[name].js', | |
assetFileNames: '[name].[ext]', | |
}, | |
}, | |
}, | |
server: { | |
open: 'http://mysite.test' | |
} | |
plugins: [], | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a work in progress. Hot Reload, the most important feature, is still not working.
Idea: Replace assets URL with
http://localhost:3000
and somehow addmodule
to the script tag?Solution that replace enqueue: https://github.com/idleberg/php-wordpress-vite-assets
Seems overkill, everything should work using the native
wp_enqueue_style
andwp_enqueue_script