This repository has been archived by the owner on Jul 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
109 lines (106 loc) · 3.11 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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin');
const AntDesignThemePlugin = require('antd-theme-webpack-plugin');
const { getLessVars } = require('antd-theme-generator');
const themeVariables = getLessVars(
path.join(__dirname, './src/styles/variables.less')
);
const lightVars = { ...getLessVars('./src/themes/light-theme.less') };
fs.writeFileSync('./src/themes/dark.json', JSON.stringify(themeVariables));
fs.writeFileSync('./src/themes/light.json', JSON.stringify(lightVars));
const options = {
antDir: path.join(__dirname, './node_modules/antd'),
stylesDir: path.join(__dirname, './src/styles'),
varFile: path.join(__dirname, './src/styles/variables.less'),
themeVariables: Array.from(new Set([...Object.keys(themeVariables)])),
generateOnce: false,
indexFileName: 'index.html'
};
const themePlugin = new AntDesignThemePlugin(options);
module.exports = {
context: __dirname,
entry: ['@babel/polyfill', './src/index.js'],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/'
},
devServer: {
host: '0.0.0.0',
port: 8000,
historyApiFallback: {
disableDotRule: true
}
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: 'babel-loader'
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
{
loader: 'file-loader',
options: {
esModule: false
}
}
]
},
{
test: /\.less$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{
loader: 'less-loader',
options: {
lessOptions: {
javascriptEnabled: true
}
}
}
]
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
}
]
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
title: process.env.LIQO_DASH_PAGE_TITLE || 'LiqoDash',
meta: {
viewport: 'width=device-width, initial-scale=1',
'theme-color': '#000000',
description: 'Liqo dashboard'
},
favicon: process.env.LIQO_DASH_FAVICON_PATH || 'src/assets/logo_4.png'
}),
themePlugin,
new AntdDayjsWebpackPlugin(),
new webpack.DefinePlugin({
'process.env.PUBLIC_PATH': JSON.stringify(''),
APISERVER_URL: JSON.stringify(process.env.APISERVER_URL),
OIDC_PROVIDER_URL: JSON.stringify(process.env.OIDC_PROVIDER_URL),
OIDC_CLIENT_ID: JSON.stringify(process.env.OIDC_CLIENT_ID),
OIDC_REDIRECT_URI: JSON.stringify(process.env.OIDC_REDIRECT_URI),
OIDC_CLIENT_SECRET: JSON.stringify(process.env.OIDC_CLIENT_SECRET)
})
]
};