Skip to content
Open
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
5 changes: 4 additions & 1 deletion .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const path = require('path');
const babelPresets = path.resolve(__dirname, 'webpack','babel', 'presets.js');

module.exports = {
presets: ['@theforeman/builder/babel'],
presets: require(babelPresets),
};
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"checkbox",
"clearbutton",
"clearfix",
"commonjs",
"comms",
"consts",
"cpu",
Expand Down
17 changes: 8 additions & 9 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const { ModuleFederationPlugin } = require('webpack').container;
var pluginUtils = require('../script/plugin_webpack_directories');
var { generateExportsFile }= require('../webpack/assets/javascripts/exportAll');
var CompressionPlugin = require('compression-webpack-plugin');
const root = path.resolve(__dirname, '..');

class AddRuntimeRequirement {
// to avoid "webpackRequire.l is not a function" error
Expand All @@ -32,7 +33,7 @@ class AddRuntimeRequirement {
}

const supportedLocales = () => {
const localeDir = path.join(__dirname, '..', 'locale');
const localeDir = path.resolve(root, 'locale');

// Find all files in ./locale/*
const localesFiles = fs.readdirSync(localeDir);
Expand Down Expand Up @@ -86,7 +87,7 @@ const commonConfig = function() {
},
},
resolveLoader: {
modules: [path.resolve(__dirname, '..', 'node_modules')],
modules: [path.resolve(root, 'node_modules')],
},
module: {
rules: [
Expand All @@ -97,7 +98,7 @@ const commonConfig = function() {
exclude: /node_modules(?!\/(@novnc|unidiff))/,
loader: 'babel-loader',
options: {
presets: [require.resolve('@theforeman/builder/babel')],
presets: [path.resolve(root, 'webpack/babel')],
},
},
{
Expand Down Expand Up @@ -152,7 +153,7 @@ const coreConfig = function() {
'..',
'webpack/assets/javascripts/bundle.js'
);
config.context = path.resolve(__dirname, '..');
config.context = root;
if (config.mode == 'production') {
var chunkFilename = '[name]-[chunkhash].js'
} else {
Expand All @@ -162,14 +163,12 @@ const coreConfig = function() {
config.entry = {
bundle: { import: bundleEntry, dependOn: ['vendor', 'reactExports'] },
vendor: vendorEntry,
reactExports: path.join(
__dirname,
'..',
reactExports: path.resolve(root,
'webpack/assets/javascripts/all_react_app_exports.js'
),
};
config.output = {
path: path.join(__dirname, '..', 'public', 'webpack'),
path: path.resolve(root, 'public', 'webpack'),
publicPath: '/webpack/',
library: {
name: ['TheForeman', '[name]'],
Expand Down Expand Up @@ -262,7 +261,7 @@ const pluginConfig = function(plugin) {
};
var configModules = config.resolve.modules || [];
// make webpack to resolve modules from core first
configModules.unshift(path.resolve(__dirname, '..', 'node_modules'));
configModules.unshift(path.resolve(root, 'node_modules'));
// add plugin's node_modules to the reslver list
configModules.push(path.resolve(pluginRoot, 'node_modules'));
configModules.push('node_modules/');
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
"react-intl": "^2.8.0"
},
"devDependencies": {
"@babel/core": "^7.7.0",
"@theforeman/builder": "^13.1.0",
"@babel/core": "~7.25.2",
"@babel/preset-env": "~7.25.2",
"@babel/preset-react": "~7.25.2",
"@theforeman/eslint-plugin-foreman": "^13.1.0",
"@theforeman/eslint-plugin-rules": "^13.1.0",
"@theforeman/test": "^13.1.0",
Expand Down
3 changes: 3 additions & 0 deletions webpack/babel/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const presets = require('./presets');

module.exports = () => ({ presets });
6 changes: 6 additions & 0 deletions webpack/babel/presets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const presets = [
[require.resolve('@babel/preset-env'), { modules: 'commonjs' }],
require.resolve('@babel/preset-react'),
];

module.exports = presets;