2021-08-02 17:24:01 +05:30
|
|
|
/*
|
2021-12-01 12:46:28 +05:30
|
|
|
* Copyright 2021 Collate
|
|
|
|
* 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 { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
|
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
|
|
const WebpackBar = require('webpackbar');
|
|
|
|
const webpack = require('webpack');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
|
|
|
|
const outputPath = path.join(__dirname, 'build');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
// Development mode
|
|
|
|
mode: 'development',
|
|
|
|
|
|
|
|
// Input configuration
|
2022-10-11 00:12:15 +05:30
|
|
|
entry: ['@babel/polyfill', path.join(__dirname, 'src/index.tsx')],
|
2021-08-01 14:27:44 -07:00
|
|
|
|
|
|
|
// Output configuration
|
|
|
|
output: {
|
|
|
|
path: outputPath,
|
|
|
|
filename: '[name].js',
|
|
|
|
chunkFilename: '[name].js',
|
|
|
|
publicPath: '/', // Ensures bundle is served from absolute path as opposed to relative
|
|
|
|
},
|
|
|
|
|
|
|
|
// Loaders
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
// .js and .jsx files to be handled by babel-loader
|
|
|
|
{
|
|
|
|
test: /\.(js|jsx)$/,
|
2021-12-28 23:16:52 +05:30
|
|
|
include: path.resolve(__dirname, 'src'),
|
2021-08-01 14:27:44 -07:00
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: ['@babel/preset-env', '@babel/preset-react'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
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: {
|
|
|
|
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
|
|
|
},
|
|
|
|
// .css and .scss files to be handled by sass-loader
|
|
|
|
// include scss rule and sass-loader if injecting scss/sass file
|
|
|
|
{
|
2021-09-09 15:14:12 +05:30
|
|
|
test: /\.(css|s[ac]ss)$/,
|
|
|
|
use: [
|
|
|
|
'style-loader',
|
|
|
|
'css-loader',
|
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
// Prefer `dart-sass`
|
|
|
|
implementation: require.resolve('sass'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'postcss-loader',
|
|
|
|
],
|
2021-12-28 23:16:52 +05:30
|
|
|
include: [
|
|
|
|
path.resolve(__dirname, 'src'),
|
|
|
|
path.resolve(__dirname, 'node_modules/tailwindcss'),
|
2022-10-18 15:30:32 +05:30
|
|
|
path.resolve(__dirname, 'node_modules/reactflow'),
|
2021-12-28 23:16:52 +05:30
|
|
|
path.resolve(__dirname, 'node_modules/react-tippy'),
|
|
|
|
path.resolve(__dirname, 'node_modules/codemirror'),
|
2022-03-07 11:04:02 +05:30
|
|
|
path.resolve(__dirname, 'node_modules/rc-tree'),
|
2022-04-09 00:45:08 -07:00
|
|
|
path.resolve(__dirname, 'node_modules/react-toastify'),
|
2022-05-23 10:57:21 +05:30
|
|
|
path.resolve(__dirname, 'node_modules/quill-emoji'),
|
2021-12-28 23:16:52 +05:30
|
|
|
],
|
|
|
|
// May need to handle files outside the source code
|
2021-08-01 14:27:44 -07:00
|
|
|
// (from node_modules)
|
|
|
|
},
|
2022-07-20 11:49:38 +05:30
|
|
|
// .less files to be handled by sass-loader
|
|
|
|
{
|
|
|
|
test: /\.less$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'style-loader',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'css-loader', // translates CSS into CommonJS
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'less-loader', // compiles Less to CSS
|
|
|
|
options: {
|
|
|
|
lessOptions: {
|
|
|
|
javascriptEnabled: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-08-01 14:27:44 -07:00
|
|
|
// .svg files to be handled by @svgr/webpack
|
|
|
|
{
|
|
|
|
test: /\.svg$/,
|
|
|
|
use: ['@svgr/webpack'],
|
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
|
|
|
},
|
2021-09-09 15:14:12 +05:30
|
|
|
// different urls to be handled by url-loader
|
2021-08-01 14:27:44 -07:00
|
|
|
{
|
2021-09-09 15:14:12 +05:30
|
|
|
test: /\.(png|jpg|jpeg|gif|svg|ico|eot|woff|woff2)$/i,
|
2021-08-01 14:27:44 -07:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'url-loader',
|
|
|
|
options: {
|
|
|
|
limit: 8192,
|
2021-09-09 15:14:12 +05:30
|
|
|
name: `[name].[ext]`,
|
2021-08-01 14:27:44 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2021-12-28 23:16:52 +05:30
|
|
|
include: [
|
|
|
|
path.resolve(__dirname, 'src'),
|
2022-07-29 18:58:41 +05:30
|
|
|
path.resolve(__dirname, 'node_modules/slick-carousel'),
|
2022-05-23 10:57:21 +05:30
|
|
|
path.resolve(__dirname, 'node_modules/quill-emoji'),
|
2021-12-28 23:16:52 +05:30
|
|
|
], // Just the source code
|
2021-09-09 15:14:12 +05:30
|
|
|
},
|
2021-08-01 14:27:44 -07:00
|
|
|
// Font files to be handled by file-loader
|
|
|
|
{
|
|
|
|
test: /\.ttf$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: '[name].[ext]',
|
|
|
|
outputPath: 'fonts/',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2022-07-29 18:58:41 +05:30
|
|
|
include: [
|
|
|
|
path.resolve(__dirname, 'src'),
|
|
|
|
path.resolve(__dirname, 'node_modules/slick-carousel'),
|
|
|
|
], // Just the source code
|
2021-09-09 15:14:12 +05:30
|
|
|
},
|
2021-08-01 14:27:44 -07:00
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
// Module resolution
|
|
|
|
resolve: {
|
|
|
|
// File types to be handled
|
|
|
|
extensions: ['.ts', '.tsx', '.js', '.jsx', '.css', '.svg', '.ttf'],
|
|
|
|
fallback: {
|
|
|
|
http: require.resolve('stream-http'),
|
|
|
|
https: require.resolve('https-browserify'),
|
2021-08-12 00:31:19 +05:30
|
|
|
path: require.resolve('path-browserify'),
|
2022-05-04 23:30:39 -07:00
|
|
|
fs: false,
|
2022-10-11 00:12:15 +05:30
|
|
|
url: require.resolve('url/'),
|
2021-08-01 14:27:44 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
// Clean webpack output directory
|
|
|
|
new CleanWebpackPlugin({
|
|
|
|
verbose: true,
|
|
|
|
}),
|
|
|
|
// In development mode, fork TypeScript checking to run in another thread and not block main
|
|
|
|
// transpilation
|
|
|
|
new ForkTsCheckerWebpackPlugin({
|
|
|
|
eslint: {
|
|
|
|
files: './src/**/*.{ts,tsx,js,jsx}',
|
|
|
|
// required - same as command `eslint ./src/**/*.{ts,tsx,js,jsx} --ext .ts,.tsx,.js,.jsx`
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
// Generate index.html from template
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
favicon: path.join(__dirname, 'public/favicon.png'),
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: path.join(__dirname, 'public/robots.txt'),
|
|
|
|
to: outputPath,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
// Build progress bar
|
|
|
|
new WebpackBar({
|
2021-08-16 18:29:24 +05:30
|
|
|
name: '@openmetadata [dev]',
|
2021-08-01 14:27:44 -07:00
|
|
|
color: '#54BAC9',
|
|
|
|
}),
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: '[name].bundle.css',
|
|
|
|
chunkFilename: '[id].css',
|
|
|
|
}),
|
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
process: 'process/browser',
|
|
|
|
Buffer: ['buffer', 'Buffer'],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
|
|
|
|
// webpack-dev-server
|
|
|
|
devServer: {
|
2022-10-07 10:10:37 +05:30
|
|
|
// Disable webpack browser window overlay
|
|
|
|
client: {
|
|
|
|
overlay: false,
|
|
|
|
},
|
|
|
|
static: {
|
|
|
|
directory: outputPath,
|
|
|
|
},
|
2021-08-01 14:27:44 -07:00
|
|
|
compress: true,
|
2022-04-24 23:45:42 +05:30
|
|
|
hot: true,
|
2021-08-01 14:27:44 -07:00
|
|
|
port: 3000,
|
2022-04-24 23:45:42 +05:30
|
|
|
open: true,
|
2021-08-01 14:27:44 -07:00
|
|
|
// Route all requests to index.html so that app gets to handle all copy pasted deep links
|
|
|
|
historyApiFallback: {
|
|
|
|
disableDotRule: true,
|
|
|
|
},
|
|
|
|
// Proxy configuration
|
|
|
|
proxy: [
|
|
|
|
{
|
|
|
|
context: '/api',
|
|
|
|
target: 'http://localhost:8585/',
|
|
|
|
changeOrigin: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
// Source map
|
|
|
|
devtool: 'eval-cheap-source-map',
|
|
|
|
};
|