Add API monorepo

Change-Id: I39aa1707744bb86c4bc9113157bbf815bb3fe33a
This commit is contained in:
Roman Jaroš 2023-09-10 21:24:57 +02:00
parent b87cff043a
commit 5246efb027
56 changed files with 251 additions and 22 deletions

View file

@ -0,0 +1,82 @@
require('ts-node/register');
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const __basedir = path.resolve(__dirname, '..');
module.exports = (env, args, myEnv) => ({
entry: {
app: [path.resolve(__basedir, 'src/index.tsx')],
style: [path.resolve(__basedir, 'src/styles/global.css')],
},
output: {
path: path.resolve(__basedir, 'build'),
publicPath: '/',
},
resolve: {
alias: {
api: path.resolve(__basedir, 'src/api'),
app: path.resolve(__basedir, 'src/app'),
components: path.resolve(__basedir, 'src/components'),
constants: path.resolve(__basedir, 'src/constants'),
features: path.resolve(__basedir, 'src/features'),
hooks: path.resolve(__basedir, 'src/hooks'),
localization: path.resolve(__basedir, 'src/localization'),
pages: path.resolve(__basedir, 'src/pages'),
utils: path.resolve(__basedir, 'src/utils'),
types: path.resolve(__basedir, 'src/types'),
},
extensions: ['.ts', '.tsx', '.js', '.json'],
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
},
{
test: /\.css$/i,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
config: path.resolve(__basedir, 'src/styles/postcss.config.js'),
},
},
},
],
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new HtmlWebPackPlugin({
hash: true,
filename: 'index.html', //target html
template: path.resolve(__basedir, 'src/app/assets/html/index.ejs'), //source html
env: {
websiteId: process.env.WA_WEBSITE_ID,
},
}),
new CopyPlugin({
patterns: [
{ from: path.resolve(__basedir, 'src/app/assets/public'), to: './' },
],
}),
new webpack.EnvironmentPlugin(myEnv),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
new CaseSensitivePathsPlugin(),
],
});

View file

@ -0,0 +1,17 @@
const { merge } = require('webpack-merge');
const common = require('./webpack-common');
const myEnv = require('dotenv').config({ path: 'config/local/.env' }).parsed;
module.exports = (env, args) => {
return merge(common(env, args, myEnv), {
mode: 'development',
devtool: 'inline-source-map',
devServer: {
host: '0.0.0.0',
port: '3330',
hot: true,
historyApiFallback: true,
},
});
};

View file

@ -0,0 +1,16 @@
const { merge } = require('webpack-merge');
const myEnv = require('dotenv').config({ path: 'config/prod/.env' }).parsed;
const common = require('./webpack-common');
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
module.exports = (env, args) => {
return merge(common(env, args, myEnv), {
mode: 'production',
devtool: false,
plugins: [
// new BundleAnalyzerPlugin(),
],
});
};