| 117 | // TODO: better error message |
| 118 | }, |
| 119 | extendWebpack( |
| 120 | cfg, |
| 121 | { |
| 122 | /*isServer, isClient*/ |
| 123 | } |
| 124 | ) { |
| 125 | // use new webpack5 loaders for asset importing |
| 126 | cfg.module.rules.push({ |
| 127 | test: /\.md/, |
| 128 | type: 'asset/source', |
| 129 | }); |
| 130 | |
| 131 | // TODO: make sure these things are only used in the browser and not in the desktop app... |
| 132 | /*cfg.node = { |
| 133 | fs: 'empty', |
| 134 | }*/ |
| 135 | |
| 136 | cfg.module.rules.push({ |
| 137 | resolve: { |
| 138 | fallback: { fs: false, net: false, tls: false }, |
| 139 | }, |
| 140 | }); |
| 141 | |
| 142 | /*if (process.env.NODE_ENV === "production") { |
| 143 | // ... |
| 144 | cfg.plugins.push( |
| 145 | new PrerenderSPAPlugin({ |
| 146 | // Required - The path to the webpack-outputted app to prerender. |
| 147 | staticDir: path.join(__dirname, 'dist/spa'), |
| 148 | // Required - Routes to render. |
| 149 | routes: [ |
| 150 | '/', // Homepage |
| 151 | // ...other routes |
| 152 | '/error-404' // 404 page, it works because this route doesn't actually exist |
| 153 | ], |
| 154 | postProcess: context => { |
| 155 | // eslint-disable-next-line @typescript-eslint/no-unsafe-call |
| 156 | context.html = context.html |
| 157 | // Defer scripts |
| 158 | .replace(/<script (.*?)>/g, '<script $1 defer>') |
| 159 | .replace('id="app"', 'id="app" data-server-rendered="true"'); |
| 160 | return context; |
| 161 | } |
| 162 | }) |
| 163 | ); |
| 164 | }*/ |
| 165 | }, |
| 166 | |
| 167 | // transpile: false, |
| 168 | |