zmk/docs/src/docusaurus-tree-sitter-plugin/index.js
Joel Spadin dae020787e docs: Update tree-sitter
Updated web-tree-sitter and the devicetree grammar.

web-tree-sitter now supports a custom function to locate its .wasm file,
so performing a string replace is no longer necessary to get it to work
with Docusaurus' Webpack configuration. We now check when tree-sitter is
locating its .wasm file and provide the Webpack-adjusted URL.
2023-05-20 01:33:11 -06:00

34 lines
740 B
JavaScript

/*
* Copyright (c) 2021 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
module.exports = function () {
return {
configureWebpack(config, isServer) {
let rules = [];
// Tree-sitter is only used for client-side code.
// Don't try to load it on the server.
if (isServer) {
rules.push({
test: /web-tree-sitter/,
loader: "null-loader",
});
}
return {
// web-tree-sitter tries to import "fs", which can be ignored.
// https://github.com/tree-sitter/tree-sitter/issues/466
resolve: {
fallback: {
fs: false,
path: false,
},
},
module: { rules },
};
},
};
};