forked from TypeScriptToLua/TypeScriptToLua.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocusaurus-plugin.js
More file actions
73 lines (69 loc) · 3.13 KB
/
docusaurus-plugin.js
File metadata and controls
73 lines (69 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const path = require("path");
const { DefinePlugin, ProvidePlugin } = require("webpack");
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
// Not used directly in playground, because it imports typescript
const { SyntaxKind: LuaSyntaxKind } = require("typescript-to-lua/dist/LuaAST");
const resolve = (query) => path.resolve(__dirname, query);
/** @returns {import('@docusaurus/types').Plugin<any>} */
module.exports = () => ({
configureWebpack: (config, isServer) => {
return {
resolveLoader: {
// Don't generate worker files in server build, because it overrides client files
alias: isServer ? { "worker-loader": require.resolve("null-loader") } : {},
},
resolve: {
alias: {
// Replace vendored monaco-typescript services build with typescript, already used by typescript-to-lua
[require.resolve("monaco-editor/esm/vs/language/typescript/lib/typescriptServices.js")]:
require.resolve("typescript"),
// Exclude builtin monaco-typescript libs
[require.resolve("monaco-editor/esm/vs/language/typescript/lib/lib.js")]: resolve(
"src/monaco-typescript-lib-stub.ts",
),
// Stub file resolution for playground
[require.resolve("typescript-to-lua/dist/transpilation/resolve.js")]:
resolve("src/resolve-stub.ts"),
},
fallback: {
fs: false,
buffer: require.resolve("buffer"),
stream: require.resolve("stream-browserify"),
zlib: require.resolve("browserify-zlib"),
path: require.resolve("path-browserify"),
},
},
module: {
rules: [
{ test: /\.ttf$/, loader: "file-loader" },
{
test: /\.scss$/,
exclude: /\.module\.scss$/,
use: [...config.module.rules.find((r) => String(r.test) === "/\\.css$/").use, "sass-loader"],
},
{
test: /\.module\.scss$/,
use: [
...config.module.rules.find((r) => String(r.test) === "/\\.module\\.css$/").use,
"sass-loader",
],
},
],
},
plugins: [
new ProvidePlugin({
process: "process/browser",
}),
new DefinePlugin({ __LUA_SYNTAX_KIND__: JSON.stringify(LuaSyntaxKind) }),
...(isServer
? []
: [
new ForkTsCheckerWebpackPlugin({
logger: { devServer: false },
typescript: { configFile: resolve("src/tsconfig.json") },
}),
]),
],
};
},
});