forked from cds-astro/aladin-lite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
148 lines (140 loc) · 4.87 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
const path = require('path');
//const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
var ROOT_PATH = path.resolve(__dirname);
var SHADER_PATH = path.resolve(ROOT_PATH, 'src/glsl');
var IMAGES_PATH = path.resolve(ROOT_PATH, 'src/img');
var CSS_PATH = path.resolve(ROOT_PATH, 'src/css');
module.exports = {
entry: './src/js/Aladin.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'aladin.js',
// Keep in dist/ only files used
clean: true,
},
resolve: {
extensions: ['.js', '.glsl', '.vert', '.frag'],
},
experiments: {
syncWebAssembly: true,
asyncWebAssembly: true,
},
performance: {
hints: false,
},
optimization: {
//minimize: false,
minimizer: [
new TerserPlugin({
terserOptions: {
mangle: true,
warnings: false,
compress: {},
safari10: true
}
}),
],
},
plugins: [
// WebGL2 app
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, "src/core"),
// Check https://rustwasm.github.io/wasm-pack/book/commands/build.html for
// the available set of arguments.
//
// Optional space delimited arguments to appear before the wasm-pack
// command. Default arguments are `--verbose`.
args: '',
// Default arguments are `--typescript --target browser --mode normal`.
extraArgs: '--no-typescript -- --features webgl2',
// Optional array of absolute paths to directories, changes to which
// will trigger the build.
// watchDirectories: [
// path.resolve(__dirname, "another-crate/src")
// ],
// The same as the `--out-dir` option for `wasm-pack`
outDir: path.resolve(__dirname, 'pkg-webgl2'),
// The same as the `--out-name` option for `wasm-pack`
outName: "core",
// If defined, `forceWatch` will force activate/deactivate watch mode for
// `.rs` files.
//
// The default (not set) aligns watch mode for `.rs` files to Webpack's
// watch mode.
// forceWatch: true,
// If defined, `forceMode` will force the compilation mode for `wasm-pack`
//
// Possible values are `development` and `production`.
//
// the mode `development` makes `wasm-pack` build in `debug` mode.
// the mode `production` makes `wasm-pack` build in `release` mode.
forceMode: "production",
// Controls plugin output verbosity, either 'info' or 'error'.
// Defaults to 'info'.
pluginLogLevel: 'info'
}),
/*
// Have this example work in Edge which doesn't ship `TextEncoder` or
// `TextDecoder` at this time.
// Maj 24/05/22: This should be supported by edge versions as of now (to be tested!)
// This save 600kB in the project!
new webpack.ProvidePlugin({
TextDecoder: ['text-encoding', 'TextDecoder'],
TextEncoder: ['text-encoding', 'TextEncoder']
}),*/
//new VueLoaderPlugin()
],
devServer: {
static: 'examples'
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ['@babel/plugin-proposal-object-rest-spread']
}
}
},
{
test: /\.(vert|frag|glsl)$/,
include: SHADER_PATH,
use: {
loader: 'webpack-glsl-minify',
options: {
output: 'source',
//preserveVariables: true,
//preserveUniforms: true,
preserveAll: true,
}
}
},
{
test: /\.(png|svg|jpg|gif)$/,
include: IMAGES_PATH,
use: [
'file-loader',
],
},
{
test: /.css$/,
//sideEffects: true,
include: CSS_PATH,
use: [
'style-loader',
'css-loader',
]
},
],
},
//mode: 'development',
mode: 'development',
//devtool: 'source-map'
};