Files
nym/ts-packages/webpack/webpack.common.js
T
Mark Sinclair 8575a72a22 Update Nym wallet dependencies to use ts-packages (#1144)
* Use shared ts-packages in wallet

* Add eslint rules

* Formatting: run eslint --fix on all files

* Formatting: fix linting errors for dependencies

* linting fixes

* fix sign in pages

* fix breaking change

* fix ts errors

fix ts and es errors

* Fix up typings for image and json modules
Add tsconfig for eslint to process webpack config

* Use shared webpack config

* Use shared logo component

* Remove unused images

* Allow html path to be passed as an argument in shared webpack config

* Fix up webpack config for html template

* Build shared ts-packages before starting dev mode

* Fix webpack config

* use shared logo component

Co-authored-by: fmtabbara <fmtabbara@hotmail.co.uk>
Co-authored-by: mmsinclair <mmsinclair@users.noreply.github.com>
2022-03-11 11:41:17 +00:00

83 lines
2.2 KiB
JavaScript

const HtmlWebpackPlugin = require('html-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
// const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const WebpackFavicons = require('webpack-favicons');
const Dotenv = require('dotenv-webpack');
const path = require('path');
/**
* Creates the default Webpack config
* @param baseDir The base directory path, e.g. pass `__dirname` of the webpack config file using this method
*/
module.exports = (baseDir, htmlPath) => ({
module: {
rules: [
{
test: /\.tsx?$/,
use: [{ loader: 'ts-loader', options: { transpileOnly: true } }],
exclude: /node_modules/,
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ['@svgr/webpack'],
},
{
test: /\.(png|jpe?g|gif|md)$/i,
// More information here https://webpack.js.org/guides/asset-modules/
type: 'asset',
},
{
// See https://webpack.js.org/guides/asset-management/#loading-fonts
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
},
{
test: /\.ya?ml$/,
type: 'json',
use: 'yaml-loader',
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
plugins: [new TsconfigPathsPlugin()],
alias: {
'react/jsx-runtime': require.resolve('react/jsx-runtime'),
},
},
plugins: [
// new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.resolve(baseDir, htmlPath || 'src/index.html'),
}),
new ForkTsCheckerWebpackPlugin({
typescript: {
mode: 'write-references',
diagnosticOptions: {
semantic: true,
syntactic: true,
},
},
}),
new WebpackFavicons({
src: path.resolve(__dirname, '../../assets/favicon/favicon.svg'), // the asset directory is relative to THIS file
}),
new Dotenv(),
],
output: {
path: path.resolve(baseDir, 'dist'),
publicPath: '/',
},
});