Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ module.exports = createConfig('eslint', {
'global-require': 'off',
'no-template-curly-in-string': 'off',
},
ignorePatterns: ['example/**/*'],
});
5 changes: 5 additions & 0 deletions config/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ module.exports = {
'import/no-import-module-export': 'off',
'react/function-component-definition': [2, { namedComponents: 'arrow-function' }],
},
settings: {
'import/resolver': {
typescript: {},
},
},
globals: {
newrelic: false,
PARAGON_THEME: false,
Expand Down
12 changes: 11 additions & 1 deletion config/webpack.common.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const fs = require('fs');
const path = require('path');
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

const ParagonWebpackPlugin = require('../lib/plugins/paragon-webpack-plugin/ParagonWebpackPlugin');
const {
Expand All @@ -11,6 +13,14 @@ const {
const paragonThemeCss = getParagonThemeCss(process.cwd());
const brandThemeCss = getParagonThemeCss(process.cwd(), { isBrandOverride: true });

const tsconfigPath = path.resolve(process.cwd(), 'tsconfig.json');
const resolvePlugins = [];

// Conditionally add TsconfigPathsPlugin if tsconfig.json exists
if (fs.existsSync(tsconfigPath)) {
resolvePlugins.push(new TsconfigPathsPlugin({ configFile: tsconfigPath }));
}

module.exports = {
entry: {
app: path.resolve(process.cwd(), './src/index'),
Expand Down Expand Up @@ -45,6 +55,7 @@ module.exports = {
'env.config': false,
},
extensions: ['.js', '.jsx', '.ts', '.tsx'],
plugins: resolvePlugins,
},
optimization: {
splitChunks: {
Expand All @@ -59,7 +70,6 @@ module.exports = {
// RemoveEmptyScriptsPlugin get rid of empty scripts generated by webpack when using mini-css-extract-plugin
// This helps to clean up the final bundle application
// See: https://www.npmjs.com/package/webpack-remove-empty-scripts#usage-with-mini-css-extract-plugin

new RemoveEmptyScriptsPlugin(),
new ParagonWebpackPlugin(),
],
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"test": "../bin/fedx-scripts.js jest ./src",
"build": "../bin/fedx-scripts.js webpack",
"lint": "../bin/fedx-scripts.js eslint . --ext .jsx,.js",
"lint": "../bin/fedx-scripts.js eslint --ext .jsx --ext .js --ext .ts --ext .tsx",
"babel": "../bin/fedx-scripts.js babel src --out-dir dist/babel --source-maps --ignore **/*.test.jsx,**/*.test.js --copy-files",
"start": "../bin/fedx-scripts.js webpack-dev-server",
"serve": "../bin/fedx-scripts.js serve"
Expand Down
8 changes: 5 additions & 3 deletions example/src/index.jsx → example/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
import App from '@src/App';

// This line is to emulate what frontend-platform does when i18n initializes.
// It's necessary because our stylesheet is generated with `[dir="ltr"]` as a prefix on all
Expand All @@ -9,5 +9,7 @@ import App from './App';
global.document.getElementsByTagName('html')[0].setAttribute('dir', 'ltr');

const rootContainer = document.getElementById('root');
const root = createRoot(rootContainer);
root.render(<StrictMode><App /></StrictMode>);
if (rootContainer) {
const root = createRoot(rootContainer);
root.render(<StrictMode><App /></StrictMode>);
}
7 changes: 5 additions & 2 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "dist"
"outDir": "dist",
"paths": {
"@src/*": ["./src/*"]
},
},
"include": [
".eslintrc.js",
Expand All @@ -13,4 +16,4 @@
"node_modules",
"dist",
]
}
}
Loading
Loading