|
@@ -1,100 +0,0 @@
|
1
|
|
-const path = require('path');
|
2
|
|
-const webpack = require('webpack');
|
3
|
|
-const TerserPlugin = require('terser-webpack-plugin');
|
4
|
|
-const pack = require('./package.json');
|
5
|
|
-
|
6
|
|
-module.exports = (env, argv) => ({
|
7
|
|
- entry: './src/main.ts',
|
8
|
|
- mode: argv.mode == 'development' ? 'development' : 'production',
|
9
|
|
- devtool: argv.mode == 'development' ? 'source-map' : undefined,
|
10
|
|
-
|
11
|
|
- output: {
|
12
|
|
- filename: !env.minimize ? 'encantar.js' : 'encantar.min.js',
|
13
|
|
- path: path.resolve(__dirname, 'dist'),
|
14
|
|
- publicPath: '/dist/',
|
15
|
|
- library: {
|
16
|
|
- name: 'AR',
|
17
|
|
- type: 'umd',
|
18
|
|
- export: 'default',
|
19
|
|
- },
|
20
|
|
- },
|
21
|
|
-
|
22
|
|
- resolve: {
|
23
|
|
- extensions: [ '.ts', '.js' ],
|
24
|
|
- symlinks: false,
|
25
|
|
- modules: [
|
26
|
|
- path.resolve(__dirname, 'src'),
|
27
|
|
- path.resolve(__dirname, '../node_modules'),
|
28
|
|
- 'node_modules',
|
29
|
|
- ],
|
30
|
|
- },
|
31
|
|
-
|
32
|
|
- plugins: [
|
33
|
|
- new webpack.BannerPlugin({
|
34
|
|
- banner: ((({ author, version, year, homepage, description, date }) => ([
|
35
|
|
- `encantar.js version ${version}`,
|
36
|
|
- `${description}`,
|
37
|
|
- `Copyright ${year} ${author}`,
|
38
|
|
- `${homepage}`,
|
39
|
|
- ``,
|
40
|
|
- `@license LGPL-3.0-or-later`,
|
41
|
|
- `Date: ${date}`,
|
42
|
|
- ].join('\n')))({
|
43
|
|
- ...pack,
|
44
|
|
- 'date': new Date().toISOString(),
|
45
|
|
- 'year': [2022, new Date().getFullYear()].join('-'),
|
46
|
|
- 'author': pack.author.replace('@', '(at)'),
|
47
|
|
- }))
|
48
|
|
- }),
|
49
|
|
- new webpack.DefinePlugin({
|
50
|
|
- '__AR_VERSION__': JSON.stringify(pack.version),
|
51
|
|
- '__AR_DEVELOPMENT_MODE__': argv.mode == 'development',
|
52
|
|
- '__AR_WEBSITE__': JSON.stringify(pack.homepage),
|
53
|
|
- }),
|
54
|
|
- new webpack.IgnorePlugin({
|
55
|
|
- resourceRegExp: /\.ignore\./i,
|
56
|
|
- }),
|
57
|
|
- ],
|
58
|
|
-
|
59
|
|
- module: {
|
60
|
|
- rules: [{
|
61
|
|
- test: /\.ts$/,
|
62
|
|
- include: path.resolve(__dirname, 'src'),
|
63
|
|
- exclude: /node_modules/,
|
64
|
|
- use: [{
|
65
|
|
- loader: 'ts-loader',
|
66
|
|
- options: {
|
67
|
|
- // improve the build time when using the dev server
|
68
|
|
- transpileOnly: env.PORT !== undefined,
|
69
|
|
- },
|
70
|
|
- }],
|
71
|
|
- }],
|
72
|
|
- },
|
73
|
|
-
|
74
|
|
- devServer: {
|
75
|
|
- server: 'https',
|
76
|
|
- host: env.HOST || '0.0.0.0',
|
77
|
|
- port: env.PORT || 8000,
|
78
|
|
- static: ['demos', 'plugins', 'tests'].map(dir => ({
|
79
|
|
- directory: path.resolve(__dirname, dir),
|
80
|
|
- publicPath: `/${dir}/`,
|
81
|
|
- })),
|
82
|
|
- headers: {
|
83
|
|
- 'Cache-Control': 'no-store',
|
84
|
|
- },
|
85
|
|
- //host: '0.0.0.0',
|
86
|
|
- //host: 'local-ip',
|
87
|
|
- },
|
88
|
|
-
|
89
|
|
- optimization: !env.minimize ? { minimize: false } : {
|
90
|
|
- minimize: true,
|
91
|
|
- minimizer: [new TerserPlugin({
|
92
|
|
- terserOptions: {
|
93
|
|
- format: {
|
94
|
|
- comments: /@license/i,
|
95
|
|
- },
|
96
|
|
- },
|
97
|
|
- extractComments: false,
|
98
|
|
- })],
|
99
|
|
- },
|
100
|
|
-});
|