Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Vuepress Markdown Variable substitution
// inside config.js extend webpack so that `__var_name__` is replaced with value of `config[var_name]`
// relies on npm install string-replace-loader
configureWebpack(config) {
config.resolve.alias["@"] = path.join(__dirname, "/theme");
config.resolve.alias["~"] = path.join(__dirname, "/public");
if (process.env.NODE_ENV === "production") {
const mappings = Object.keys(config).map(key => {
return { search: `__${key}__`, replace: config[key] }
test: /\.*/,
loader: "string-replace-loader",
options: {
multiple: mappings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.