-
Notifications
You must be signed in to change notification settings - Fork 8
/
webpack.config.js
125 lines (114 loc) · 3.48 KB
/
webpack.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
var path = require("path");
var os = require("os");
var fs = require("fs");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var { TsconfigPathsPlugin } = require("tsconfig-paths-webpack-plugin");
var __DEV__ = process.argv.includes("serve");
//clean previous build output
require("rimraf").sync(path.join(__dirname, "dist"));
module.exports = {
mode: "development",
devtool: __DEV__ ? "inline-source-map" : "source-map",
entry: {
ocean: path.join(__dirname, "src/index.ts"),
},
output: {
//using [name] allows for code splitting. chunkhash in prod for cash busting
filename: __DEV__ ? "[name].js" : "[name].[chunkhash].js",
path: path.join(__dirname, "dist"),
},
resolve: {
extensions: [".ts", ".tsx", ".jsx", ".js"],
fallback: {
fs: false,
path: false,
},
plugins: [new TsconfigPathsPlugin()],
},
module: {
rules: [
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
{
test: /\.(js|mjs|jsx|ts|tsx)$/,
loader: "source-map-loader",
enforce: "pre",
},
{
test: /\.tsx?$/,
loader: "ts-loader",
},
{
test: /\.(png|jpg|gif|env|glb|stl|exr|hdr)$/i,
use: [
{
loader: "url-loader",
options: {
limit: 8192,
},
},
],
},
{
test: /\.(wgsl|glsl)$/i,
use: [
{
loader: "raw-loader",
},
],
},
],
},
plugins: [
//new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
inject: true,
template: path.join(__dirname, "src/index.html"),
}),
],
devServer: {
static: {
directory: path.join(__dirname, "src"),
},
open: {
app: {
name: getCanaryPath(),
arguments: ["--enable-unsafe-webgpu"],
},
},
},
};
function getWindowsBrowserCmd() {
let windowsCanaryPath = path.normalize(
path.join(
os.homedir(),
"AppData/Local/Google/Chrome SxS/Application/chrome.exe"
)
);
let isCanaryInstalled = fs.existsSync(windowsCanaryPath);
let windowsBrowserCmd = isCanaryInstalled
? windowsCanaryPath
: require("open").apps.chrome;
return windowsBrowserCmd;
}
function getCanaryPath() {
switch (os.platform) {
case "win32":
return getWindowsBrowserCmd();
case "darwin":
return require("open").apps.chrome;
case "linux":
return require("open").apps.chrome;
default:
return require("open").apps.chrome;
}
}
//I've never owned a mac , someone who has please configure the darwin switch above to return whatever is proper
//https://developers.google.com/web/updates/2017/04/headless-chrome
// alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
// alias chrome-canary="/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary"
// alias chromium="/Applications/Chromium.app/Contents/MacOS/Chromium"