forked from webgpu/webgpu-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
57 lines (51 loc) · 1.64 KB
/
next.config.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
53
54
55
56
57
const path = require('path');
const fs = require('fs');
const BASE_PATH = process.env.BASE_PATH || '';
module.exports = {
target: 'serverless',
basePath: BASE_PATH,
compress: true,
reactStrictMode: true,
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.module.rules.push({
test: /\.(png|jpe?g|gif|webm)$/i,
use: {
loader: 'file-loader',
options: {
esModule: false,
publicPath: path.join('/', BASE_PATH, '_next/static'),
outputPath: 'static',
},
},
});
config.module.rules.push({
test: /\.wgsl$/i,
use: 'raw-loader',
});
config.plugins.push(new webpack.DefinePlugin({
__SOURCE__: webpack.DefinePlugin.runtimeValue((v) => {
// Load the source file and set it as a global definition.
// This is useful for easily embedding a file's source into the page.
let filePath = v.module.rawRequest;
filePath = filePath.replace(
'private-next-pages',
path.join(__dirname, 'src/pages')
);
if (!path.isAbsolute(filePath)) {
// Path is relative to some path in src/pages/samples.
filePath = path.resolve(
path.join(__dirname, 'src', 'pages', 'samples'),
filePath
);
filePath = `${filePath}.ts`;
}
const source = fs.readFileSync(filePath, 'utf-8');
return JSON.stringify(source); // Strings need to be wrapped in quotes
}, []),
})
);
config.node.__filename = true;
config.node.__dirname = true;
return config;
},
}