2021-08-02 17:24:01 +05:30
|
|
|
/*
|
2022-12-27 12:37:58 +05:30
|
|
|
* Copyright 2022 Collate.
|
2021-12-01 12:46:28 +05:30
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2021-08-02 17:24:01 +05:30
|
|
|
|
2021-08-01 14:27:44 -07:00
|
|
|
const path = require('path');
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2024-09-30 12:22:52 +05:30
|
|
|
const process = require('process');
|
2024-10-03 10:27:00 +05:30
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
2021-08-01 14:27:44 -07:00
|
|
|
|
2021-12-28 23:16:52 +05:30
|
|
|
const outputPath = path.join(__dirname, 'dist/assets');
|
2024-09-30 12:22:52 +05:30
|
|
|
const subPath = process.env.APP_SUB_PATH ?? '';
|
2021-08-01 14:27:44 -07:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
// Production mode
|
|
|
|
mode: 'production',
|
|
|
|
|
|
|
|
// Input configuration
|
2024-09-30 12:22:52 +05:30
|
|
|
entry: path.join(__dirname, 'src/index.tsx'),
|
2021-08-01 14:27:44 -07:00
|
|
|
|
|
|
|
// Output configuration
|
|
|
|
output: {
|
|
|
|
path: outputPath,
|
2024-01-10 16:10:54 +05:30
|
|
|
filename: 'openmetadata.[fullhash].js',
|
|
|
|
chunkFilename: '[name].[fullhash].js',
|
2024-09-30 12:22:52 +05:30
|
|
|
// Clean the output directory before emit.
|
|
|
|
clean: true,
|
|
|
|
// Ensures bundle is served from absolute path as opposed to relative
|
|
|
|
publicPath: `${subPath ?? ''}/`,
|
2021-08-01 14:27:44 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
// Loaders
|
|
|
|
module: {
|
|
|
|
rules: [
|
2022-04-06 21:11:46 +05:30
|
|
|
// .mjs files to be handled
|
|
|
|
{
|
|
|
|
test: /\.m?js/,
|
|
|
|
include: path.resolve(__dirname, 'node_modules/kleur'),
|
|
|
|
resolve: {
|
|
|
|
fullySpecified: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2021-08-01 14:27:44 -07:00
|
|
|
// .ts and .tsx files to be handled by ts-loader
|
|
|
|
{
|
|
|
|
test: /\.(ts|tsx)$/,
|
|
|
|
loader: 'ts-loader',
|
|
|
|
options: {
|
2023-01-06 19:44:57 +05:30
|
|
|
configFile: 'tsconfig.json',
|
2021-08-01 14:27:44 -07:00
|
|
|
transpileOnly: true, // Speed up compilation in development mode
|
|
|
|
},
|
2021-12-28 23:16:52 +05:30
|
|
|
include: path.resolve(__dirname, 'src'), // Just the source code
|
2021-08-01 14:27:44 -07:00
|
|
|
},
|
2024-09-30 12:22:52 +05:30
|
|
|
// .css files to be handled by style-loader & css-loader
|
2021-08-01 14:27:44 -07:00
|
|
|
{
|
2024-09-30 12:22:52 +05:30
|
|
|
test: /\.(css)$/,
|
|
|
|
use: ['style-loader', 'css-loader'],
|
2021-08-01 14:27:44 -07:00
|
|
|
},
|
2024-09-30 12:22:52 +05:30
|
|
|
// .less files to be handled by less-loader
|
2022-07-20 11:49:38 +05:30
|
|
|
{
|
|
|
|
test: /\.less$/,
|
|
|
|
use: [
|
2024-09-30 12:22:52 +05:30
|
|
|
'style-loader',
|
|
|
|
'css-loader',
|
2024-07-01 14:59:25 +05:30
|
|
|
'postcss-loader',
|
2022-07-20 11:49:38 +05:30
|
|
|
{
|
2024-09-30 12:22:52 +05:30
|
|
|
loader: 'less-loader',
|
2022-07-20 11:49:38 +05:30
|
|
|
options: {
|
|
|
|
lessOptions: {
|
|
|
|
javascriptEnabled: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-08-01 14:27:44 -07:00
|
|
|
// .svg files to be handled by @svgr/webpack
|
|
|
|
{
|
|
|
|
test: /\.svg$/,
|
2024-09-30 12:22:52 +05:30
|
|
|
use: ['@svgr/webpack', 'url-loader'],
|
2021-12-28 23:16:52 +05:30
|
|
|
include: path.resolve(__dirname, 'src'), // Just the source code
|
2021-08-01 14:27:44 -07:00
|
|
|
},
|
2024-09-30 12:22:52 +05:30
|
|
|
// images files to be handled by file-loader
|
2021-08-01 14:27:44 -07:00
|
|
|
{
|
2024-09-30 12:22:52 +05:30
|
|
|
test: /\.png$/,
|
2021-08-01 14:27:44 -07:00
|
|
|
use: [
|
|
|
|
{
|
2024-09-30 12:22:52 +05:30
|
|
|
loader: 'file-loader',
|
2021-08-01 14:27:44 -07:00
|
|
|
options: {
|
2024-09-30 12:22:52 +05:30
|
|
|
name: '[name].[ext]',
|
|
|
|
outputPath: 'images/',
|
2021-08-01 14:27:44 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2021-09-09 15:14:12 +05:30
|
|
|
},
|
2021-08-01 14:27:44 -07:00
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
// Module resolution
|
|
|
|
resolve: {
|
|
|
|
// File types to be handled
|
2024-09-30 12:22:52 +05:30
|
|
|
extensions: ['.ts', '.tsx', '.js', '.css', '.less', '.svg'],
|
2021-08-01 14:27:44 -07:00
|
|
|
fallback: {
|
|
|
|
https: require.resolve('https-browserify'),
|
2022-05-04 23:30:39 -07:00
|
|
|
fs: false,
|
2024-01-03 21:40:23 -08:00
|
|
|
'process/browser': require.resolve('process/browser'),
|
|
|
|
},
|
|
|
|
alias: {
|
|
|
|
process: 'process/browser',
|
2024-11-27 01:26:57 +05:30
|
|
|
Quill: path.resolve(__dirname, 'node_modules/quill'), // Alias for the 'quill' library in node_modules
|
2021-08-01 14:27:44 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
2024-10-03 10:27:00 +05:30
|
|
|
// Clean webpack output directory
|
|
|
|
new CleanWebpackPlugin({
|
|
|
|
verbose: true,
|
|
|
|
}),
|
2021-08-01 14:27:44 -07:00
|
|
|
// Generate index.html from template
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
favicon: path.join(__dirname, 'public/favicon.png'),
|
2021-09-22 09:04:17 +05:30
|
|
|
hash: true,
|
2022-07-28 17:24:22 +05:30
|
|
|
cache: false,
|
2021-08-01 14:27:44 -07:00
|
|
|
template: path.join(__dirname, 'public/index.html'),
|
|
|
|
scriptLoading: 'defer',
|
|
|
|
}),
|
|
|
|
// Copy favicon, logo and manifest for index.html
|
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: path.join(__dirname, 'public/favicon.png'),
|
|
|
|
to: outputPath,
|
|
|
|
},
|
|
|
|
{
|
2024-09-17 19:16:59 +05:30
|
|
|
from: path.join(__dirname, 'public/favicons/favicon-16x16.png'),
|
|
|
|
to: outputPath,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: path.join(__dirname, 'public/favicons/favicon-32x32.png'),
|
|
|
|
to: outputPath,
|
|
|
|
},
|
|
|
|
{
|
2021-08-01 14:27:44 -07:00
|
|
|
from: path.join(__dirname, 'public/logo192.png'),
|
|
|
|
to: outputPath,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: path.join(__dirname, 'public/manifest.json'),
|
|
|
|
to: outputPath,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: path.join(__dirname, 'public/swagger.html'),
|
|
|
|
to: outputPath,
|
|
|
|
},
|
2023-03-21 18:43:41 +05:30
|
|
|
{
|
|
|
|
from: path.join(__dirname, 'public/locales'),
|
|
|
|
to: outputPath,
|
|
|
|
},
|
2021-08-01 14:27:44 -07:00
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
};
|