-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.js
101 lines (94 loc) · 2.65 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
/*
* Copyright (c) 2020-24 Prolincur Technologies LLP.
* All Rights Reserved.
*/
import webpack from 'webpack'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import nodeExternals from 'webpack-node-externals'
import path from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const webpackEnv = process.env.NODE_ENV || 'production'
const isDev = webpackEnv === 'development'
const config = {
mode: webpackEnv,
devtool: isDev ? 'inline-source-map' : undefined,
entry: {
'three-dxf-loader': './src/loader/index.js',
'three-dxf-viewer': './src/viewer/index.js',
},
experiments: {
outputModule: true,
},
output: {
filename: '[name].js',
// path: path.resolve(__dirname, 'dist'),
library: { type: 'module' },
environment: { module: true },
globalObject: 'this',
},
externalsType: 'module',
externals: [
'three',
'three/examples/jsm/geometries/TextGeometry.js',
'three/examples/jsm/controls/OrbitControls.js'
],
module: {
rules: [
{
test: /\.m?js/,
type: 'javascript/auto',
},
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
],
},
plugins: [
new webpack.BannerPlugin(
'Copyright (c) 2021-24 Prolincur Technologies LLP.\nCopyright (c) 2015 GDS Storefront Estimating\nAll Rights Reserved.\n\n' +
'Please check the provided LICENSE file for licensing details.\n' +
'\n' +
'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n' +
'INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n' +
'PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n' +
'LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT\n' +
'OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n' +
'OTHER DEALINGS IN THE SOFTWARE.\n'
),
],
}
const nodeConfig = {
...config,
target: 'node',
externals: [
...config.externals,
nodeExternals()
],
output: {
...config.output,
path: path.resolve(__dirname, 'dist/node'),
chunkFormat: 'module',
}
}
const browserConfig = {
...config,
target: 'web',
output: {
...config.output,
// path: path.resolve(__dirname, 'dist/browser'),
path: path.resolve(__dirname, 'dist'),
},
plugins: [
...config.plugins,
new HtmlWebpackPlugin({
title: 'Production',
}),
]
}
// export default [nodeConfig, browserConfig]
export default [browserConfig]