-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
184 lines (180 loc) · 5.16 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const FileManagerPlugin = require('filemanager-webpack-plugin');
const autoprefixer = require('autoprefixer')
const sveltePreprocess = require('svelte-preprocess');
const mode = process.env.NODE_ENV || 'development';
const prod = mode === 'production';
module.exports = {
entry: {
'./code/bundle': ['./src/main.js'],
// home: {import: './pages/index.html', filename: '[name].html'},
},
output: {
path: path.join(__dirname, '/public'),
//path: path.resolve(__dirname, 'public'),
filename: '[name].js',
chunkFilename: '[name].[id].js',
clean: true,
},
resolve: {
alias: {
svelte: path.resolve('node_modules', 'svelte/src/runtime')
},
extensions: ['.mjs', '.js', '.svelte' ],
mainFields: ['svelte', 'browser', 'module', 'main'],
conditionNames: ['svelte', 'browser']
},
module: {
rules: [
{
test: /\.(htm|svelte)$/,
use: {
loader: 'svelte-loader',
options: {
compilerOptions: {
dev: !prod
},
emitCss: prod,
hotReload: !prod,
noReload: false,
optimistic: false,
//preprocess: sveltePreprocess(),
}
},
},
{
test: /\.ls$/,
type: 'asset/source',
},
{
test: /.*\.m?js$/,
resolve: {
fullySpecified: false,
}
},
{
test: /\.css$/,
exclude: /svelte\.\d+\.css/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader'
]
},
{
test: /\.css$/,
include: /svelte\.\d+\.css/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
sourceMap: true,
}
}
]
},
{
test: /\.(scss)$/,
use: [
{
// Adds CSS to the DOM by injecting a `<style>` tag
//loader: 'style-loader'
loader: MiniCssExtractPlugin.loader
},
{
// Interprets `@import` and `url()` like `import/require()` and will resolve them
loader: 'css-loader'
},
{
// Loader for webpack to process CSS with PostCSS
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
autoprefixer
]
}
}
},
{
// Loads a SASS/SCSS file and compiles it to CSS
loader: 'sass-loader'
}
]
}
]
},
mode,
devtool: 'source-map',
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css'
}),
// new HtmlWebpackPlugin({
// template: './pages/index.html'
// }),
new FileManagerPlugin({
events: {
onStart: {
delete: [ './public' ],
},
onEnd: {
mkdir: ['./public', './public/code', './public/code/user', './public/assets/examples'],
copy: [
{ source: './node_modules/bootstrap/dist/js/bootstrap.bundle.min.js',
destination: './public/code/vendor/',
},
{ source: './node_modules/mathjs/lib/browser/math.js',
destination: './public/code/vendor/',
},
{ source: './node_modules/babylonjs/babylon.js',
destination: './public/code/vendor/babylonjs/',
},
{ source: './node_modules/babylonjs-serializers/babylonjs.serializers.min.js',
destination: './public/code/vendor/babylonjs/',
},
{ source: './node_modules/babylonjs-materials/babylonjs.materials.min.js',
destination: './public/code/vendor/babylonjs/',
},
{ source: './node_modules/babylonjs-procedural-textures/babylon.grassProceduralTexture.min.js',
destination: './public/code/vendor/babylonjs/',
},
{ source: './node_modules/babylonjs-gui/babylon.gui.min.js',
destination: './public/code/vendor/babylonjs/',
},
{ source: './src/lib/classconst.js', destination: './public/code/'},
{ source: './src/lib/plainjs/*.js', destination: './public/code/'},
{ source: './src/user/*.js', destination: './public/code/user'},
{ source: './assets/*.ico', destination: './public' },
{ source: './assets/*.png', destination: './public' },
{ source: './assets/*.json', destination: './public/assets' },
{ source: './assets/examples/**/', destination: './public/assets/examples' },
{ source: './pages/*.html', destination: './public/'},
{ source: './pages/*.pdf', destination: './public/'},
],
}
}
})
],
stats: {
builtAt: true,
},
devtool: prod ? false : 'source-map',
devServer: {
hot: true,
client: {
overlay: {
errors: true,
warnings: false,
runtimeErrors: false,
},
},
watchFiles: ['public/*.html'],
static: {
directory: path.join(__dirname,'public'),
}
}
};