-
Notifications
You must be signed in to change notification settings - Fork 104
Local Development Setup for CSS and JS
This guide explains how to set up a local development environment to test CSS and JavaScript changes.
The goal is to run a local proxy (mitmproxy) that intercepts requests from the live liquipedia.net site and replaces the production CSS and JS files with your local, compiled versions.
This allows you to see your changes live on the real site before pushing them.
mitmproxy is a Python tool. We'll install it with pip.
# Install pip if you don't have it
sudo pacman -S python-pip
# Install mitmproxy
pip install mitmproxy
# Add the install location to your PATH
# Add this to your ~/.bashrc (or whatever shell you use)
export PATH="$PATH:/home/YOUR_USER/.local/bin"
# Reload your shell
source ~/.bashrcmitmproxy needs to decrypt https traffic, and your browser will block this unless you tell it to trust mitmproxy.
-
Run
mitmproxy: In a terminal, just runmitmproxyonce.On Windows, you have to setup the computer proxy to
localhost:8080before can access the mitm.it url. -
Get the Certificate: Open browser and visit
http://mitm.it. Click your OS icon to downloadmitmproxy-ca-cert.pem. -
Import Certificate:
- In Brave / your browser, go to
brave://settings/security. - Click "Manage certificates".
- Go to the "Custom" page.
- Click "Import..." and select the
.pemfile you just downloaded. - Click OK.
- In Brave / your browser, go to
-
Disable System Proxy: Go back to your Arch Network Settings and disable the manual proxy.
This is much easier than toggling your system proxy.
- In Brave / your browser, install "Proxy SwitchyOmega" from the Chrome Web Store.
- Open its Options.
- Create a New profile named
mitmproxy. - Set the profile to:
-
Protocol:
HTTP -
Server:
127.0.0.1 -
Port:
8080
-
Protocol:
- Click "Apply changes".
To save you from typing the long mitmproxy command, add these functions to your ~/.bashrc (or ~/.zshrc):
Remember to replace the file paths.
# replaces both js and css files with local counterparts
function proxy_lp() {
mitmproxy \
--map-local "|liquipedia\.net/commons/load\.php.*only=styles|/PATH-TO-REPO/Lua-Modules/lua/output/css/main.css" \
--map-local "|liquipedia\.net/commons/load\.php.*only=scripts|/PATH-TO-REPO/Lua-Modules/lua/output/js/main.js"
}
# replaces just the css file with local counterpart
function proxy_lp_css() {
mitmproxy --map-local "|liquipedia\.net/commons/load\.php.*only=styles|/PATH-TO-REPO/Lua-Modules/lua/output/css/main.css"
}
# replaces just the js file with local counterpart
function proxy_lp_js() {
mitmproxy --map-local "|liquipedia\.net/commons/load\.php.*only=scripts|/PATH-TO-REPO/Lua-Modules/lua/output/js/main.js"
}Reload your shell with source ~/.bashrc.
Add this to your Neovim keymaps file to run the build with <leader>rb. These scripts run the JS/CSS or both build commands when operating within Lua-Modules.
vim.keymap.set("n", "<leader>rb", function()
vim.notify("π Running npm run build...", vim.log.levels.INFO)
vim.fn.system('npm run build')
if vim.v.shell_error == 0 then
vim.notify("π Liquipedia JS/CSS built successfully!", vim.log.levels.INFO)
else
vim.notify("β Liquipedia JS/CSS build failed!", vim.log.levels.ERROR)
end
end, { noremap = true, silent = true, desc = "Build Liquipedia JS/CSS" })
vim.keymap.set("n", "<leader>rj", function()
vim.notify("π Running npm run build:js...", vim.log.levels.INFO)
vim.fn.system('npm run build:js')
if vim.v.shell_error == 0 then
vim.notify("π Liquipedia JS built successfully!", vim.log.levels.INFO)
else
vim.notify("β Liquipedia JS build failed!", vim.log.levels.ERROR)
end
end, { noremap = true, silent = true, desc = "Build Liquipedia JS" })
vim.keymap.set("n", "<leader>rc", function()
vim.notify("π Running npm run build:css...", vim.log.levels.INFO)
vim.fn.system('npm run build:css')
if vim.v.shell_error == 0 then
vim.notify("π Liquipedia CSS built successfully!", vim.log.levels.INFO)
else
vim.notify("β Liquipedia CSS build failed!", vim.log.levels.ERROR)
end
end, { noremap = true, silent = true, desc = "Build Liquipedia CSS" })
You're all set. Here is your daily process.
-
Start the Proxy: Open a terminal and run your new alias:
proxy_lp
(Leave this terminal running).
-
Enable the Proxy in Brave: Click the Proxy SwitchyOmega icon in your toolbar and select the
mitmproxyprofile. -
Edit and Build:
- In Neovim, make your changes to any
.scssor.jsfile inside theLua-Modulesdirectory. - When ready, press
<leader>rbto build. - You'll see a "Build complete!" notification.
- In Neovim, make your changes to any
-
View Changes: Refresh the Liquipedia page in Brave. (Use Ctrl+Shift+R for a hard reload if your changes don't appear).
-
When You're Done:
- Stop the proxy: Press
qandyin themitmproxyterminal. - Disable the proxy: Click the SwitchyOmega icon and select
[Direct].
- Stop the proxy: Press