seedling/source/ui/scripts/webpack-common.js
Roman Jaroš 5246efb027 Add API monorepo
Change-Id: I39aa1707744bb86c4bc9113157bbf815bb3fe33a
2023-09-10 22:25:09 +02:00

82 lines
2.1 KiB
JavaScript

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(),
],
});