Skip to content

Commit 2063807

Browse files
committed
refactor(babel): convert from import to require in webpack configs and correct babel config resolve
1 parent 3d1634b commit 2063807

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

scripts/webpack/webpack.base.babel.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import path from 'path';
1+
const path = require('path');
22

3-
import webpack from 'webpack';
4-
import dotenv from 'dotenv';
5-
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
6-
7-
import {version} from '../../package.json';
3+
const webpack = require('webpack');
4+
const dotenv = require('dotenv');
5+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
86

97
const postcssPresetEnv = require('postcss-preset-env');
108

9+
const {version} = require('../../package.json');
10+
1111
dotenv.config();
1212

1313
process.env.REACT_CISCOSPARK_VERSION = version;
1414

15-
export default (options, env) => {
15+
module.exports = (options, env) => {
1616
const packageJson = require('../../package.json');
1717
const plugins = [
1818
new webpack.EnvironmentPlugin([
@@ -75,7 +75,12 @@ export default (options, env) => {
7575
'/__fixtures__/',
7676
'/__mocks__/'
7777
],
78-
use: ['babel-loader']
78+
use: {
79+
loader: 'babel-loader',
80+
options: {
81+
rootMode: 'upward'
82+
}
83+
}
7984
},
8085
{
8186
test: /\.css$/,

scripts/webpack/webpack.dev.babel.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
* webpack dev server and we are bundling into a single js file.
44
*/
55

6-
import webpack from 'webpack';
7-
import HtmlWebpackPlugin from 'html-webpack-plugin';
6+
const webpack = require('webpack');
7+
const HtmlWebpackPlugin = require('html-webpack-plugin');
88

9-
import webpackConfigBase from './webpack.base.babel';
9+
const webpackConfigBase = require('./webpack.base.babel');
1010

1111
const plugins = [
1212
new HtmlWebpackPlugin({
@@ -26,7 +26,7 @@ const plugins = [
2626
];
2727

2828
// env config object from command line: https://webpack.js.org/guides/environment-variables/
29-
export default (env) => webpackConfigBase({
29+
module.exports = (env) => webpackConfigBase({
3030
entry: './index.js',
3131
mode: 'development',
3232
plugins,

scripts/webpack/webpack.prod.babel.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
*/
44
/* eslint no-sync:0 */
55

6-
import path from 'path';
7-
import fs from 'fs';
6+
const path = require('path');
7+
const fs = require('fs');
88

9-
import webpack from 'webpack';
10-
import HtmlWebpackPlugin from 'html-webpack-plugin';
9+
const webpack = require('webpack');
10+
const HtmlWebpackPlugin = require('html-webpack-plugin');
1111

12-
import webpackBaseConfig from './webpack.base.babel';
12+
const webpackBaseConfig = require('./webpack.base.babel');
1313

1414
const plugins = [
1515
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
@@ -48,7 +48,7 @@ if (fs.existsSync('./src/index.html')) {
4848
const publicPath = process.env.BUILD_PUBLIC_PATH;
4949

5050
// env config object from command line: https://webpack.js.org/guides/environment-variables/
51-
export default (env) => webpackBaseConfig({
51+
module.exports = (env) => webpackBaseConfig({
5252
mode: 'production',
5353
entry: './index.js',
5454
output: {

webpack.config.babel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Config for starting Dev Server
2-
import webpackDevConfig from './scripts/webpack/webpack.dev.babel';
2+
const webpackDevConfig = require('./scripts/webpack/webpack.dev.babel');
33

44
export default webpackDevConfig;

0 commit comments

Comments
 (0)