title: how to import module.exports in webpack
body: <p>I am trying to refactor some webpack settings (in my package.json) that I currently have, as I have 4 files with almost the same code, some constants are different:</p>
  <pre><code>&quot;scripts&quot;: {
    &quot;build:something&quot;: &quot;NODE_ENV=production webpack --mode=production --progress --config webpack.prod.something.js&quot;,
    &quot;build:something2&quot;: &quot;NODE_ENV=production webpack --mode=production --progress --config webpack.prod.something2.js&quot;,
    &quot;build:something3&quot;: &quot;NODE_ENV=production webpack --mode=production --progress --config webpack.prod.something3.js&quot;,
    &quot;build:something4&quot;: &quot;NODE_ENV=production webpack --mode=production --progress --config webpack.prod.something4.js&quot;,
  }
  </code></pre>
  <p>and this code what shows in the webpack.prod.something1.js, ...</p>
  <pre><code>'use strict';
  
  const webpack = require('webpack');
  const VueLoaderPlugin = require('vue-loader/lib/plugin');
  const { CleanWebpackPlugin } = require('clean-webpack-plugin');
  const HtmlWebpackPlugin = require('html-webpack-plugin');
  const TerserPlugin = require('terser-webpack-plugin');
  const CopyPlugin = require('copy-webpack-plugin');
  
  const fs = require('fs'); 
  const DEFAULTLANG = 'en'; // this is different in each brand
  const CURRENT_BRAND = 'something'; // this is different in each brand
  const API_URL = ''; // Development Backend API testing URL
  const IPG_URL = 'https://test.com'; // this is different in each brand
  const packageJson = fs.readFileSync('./package.json');
  const version = JSON.parse(packageJson).version || 0;
  
  module.exports = {
      mode: 'production',
      entry: {
          main: './src/js/main.js'
      },
      output: {
          path: path.resolve(__dirname, './dist'),
          publicPath: '/',
          filename: '[name].js',
          chunkFilename: '[name].chunk.js',
      }, ....
  </code></pre>
  <p>I tried to create a separated file <em>settings.js</em>, with all the <strong>module.exports</strong> code, and import it with require, but it tries to execute <strong>path.resolve</strong> and all the rest of the function inside of it.</p>
  <p>I just wanted it to import it and execute all the functions when everything is imported and execute it in each something.js file.</p>
  <p>Any Ideas on how to do this?
  Thanks</p>