forked from Canadian-Geospatial-Platform/app.geo.ca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
99 lines (95 loc) · 2.88 KB
/
webpack.common.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
/* eslint-disable prettier/prettier */
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable @typescript-eslint/no-var-requires */
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
// const DotEnv = require('dotenv-webpack');
// const childProcess = require('child_process');
const package = require('./package.json');
// get version numbers and the hash of the current commit
const [major, minor, patch] = package.version.split('.');
// const hash = JSON.stringify(childProcess.execSync('git rev-parse HEAD').toString().trim());
console.log(`Build CGP Viewer: ${major}.${minor}.${patch}`);
const config = {
entry: path.resolve(__dirname, 'src/app.tsx'),
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: 'gcpv-main.js',
},
resolve: {
extensions: ['.mjs', '.ts', '.tsx', '.js', '.jsx', '.json', '.jpg'],
fallback: {
"fs": false,
"tls": false,
"net": false,
"path": false,
"zlib": false,
"http": false,
"https": false,
"stream": false,
"crypto": false,
"crypto-browserify": false,
},
},
performance: {
maxEntrypointSize: 2048000,
maxAssetSize: 4096000
},
module: {
rules: [
{
test: /.(ts|tsx|js|jsx)$/,
exclude: [path.resolve(__dirname, 'node_modules')],
loader: 'babel-loader',
},
{
test: /\.s?[ac]ss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader',
},
],
},
{
test: /\.svg$/,
use: ['@svgr/webpack'],
},
],
},
plugins: [
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, 'public/assets'),
to: path.resolve(__dirname, 'dist/assets'),
force: true
},
{
from: path.resolve(__dirname, 'public/root'),
to: path.resolve(__dirname, 'dist/'),
force: true
}
]
}),
new HtmlWebpackPlugin({
template: './public/index.html',
title: 'GEO.CA Viewer',
}),
new webpack.DefinePlugin({
__VERSION__: {
major,
minor,
patch,
timestamp: Date.now(),
},
})
],
};
module.exports = config;