-
Notifications
You must be signed in to change notification settings - Fork 21
/
docusaurus-plugin.js
52 lines (49 loc) · 2.14 KB
/
docusaurus-plugin.js
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
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: {
// tsWorker downloaded by fetch-tsworker.js for our current TS version
["cdn.tsWorker"]: resolve("static/cdn.tsWorker.js"),
// Stub file resolution for playground
[require.resolve("typescript-to-lua/dist/transpilation/resolve.js")]:
resolve("src/resolve-stub.ts"),
},
fallback: {
os: false,
fs: false,
perf_hooks: false,
buffer: require.resolve("buffer"),
stream: require.resolve("stream-browserify"),
zlib: require.resolve("browserify-zlib"),
path: require.resolve("path-browserify"),
},
},
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") },
}),
]),
],
};
},
});