Skip to content

Commit

Permalink
Remove import/no-unresolved from .eslintrc.js (opensearch-project#584)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergey Myssak <[email protected]>
Signed-off-by: Andrey Myssak <[email protected]>
  • Loading branch information
andreymyssak and SergeyMyssak committed May 29, 2023
1 parent 7566d07 commit a3ff60f
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 117 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ module.exports = {
plugins: ['jsx-a11y', 'prettier', 'local', 'react-hooks'],
rules: {
'prefer-template': 'error',
'import/no-unresolved': 'off',
'local/i18n': 'error',
'local/href-with-rel': 'error',
'local/forward-ref': 'error',
Expand Down
223 changes: 107 additions & 116 deletions src-docs/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ const babelConfig = require('./.babelrc.js');
// const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');

const getPort = require('get-port');

const { NODE_ENV, CI, WEBPACK_SERVE } = process.env;

const isDevelopment = WEBPACK_SERVE === 'true' && CI == null;
Expand All @@ -40,133 +38,126 @@ function employCache(loaders) {
return loaders;
}

const webpackConfig = async () => {
const port = await getPort({
port: getPort.makeRange(8030, 8130),
host: '0.0.0.0',
});
const webpackConfig = {
mode: isProduction ? 'production' : 'development',

return {
mode: isProduction ? 'production' : 'development',
devtool: isProduction ? 'source-map' : 'cheap-module-source-map',

devtool: isProduction ? 'source-map' : 'cheap-module-source-map',
entry: {
bundle: './index.js',
},

entry: {
bundle: './index.js',
},
context: path.resolve(__dirname, 'src'),

context: path.resolve(__dirname, 'src'),
output: {
path: path.resolve(__dirname, '../docs'),
filename: `[name]${isProduction ? '.min' : ''}.js`,
},

output: {
path: path.resolve(__dirname, '../docs'),
filename: `[name]${isProduction ? '.min' : ''}.js`,
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'],
fallback: {
fs: false,
},

resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'],
fallback: {
fs: false,
},
},

resolveLoader: {
alias: {
'prop-loader': path.resolve(
__dirname,
'../scripts/loaders/prop-loader.js'
),
},
},

resolveLoader: {
alias: {
'prop-loader': path.resolve(
__dirname,
'../scripts/loaders/prop-loader.js'
),
module: {
rules: [
{
resourceQuery: /raw/,
type: 'asset/source',
},
},

module: {
rules: [
{
resourceQuery: /raw/,
type: 'asset/source',
},
{
test: /\.(js|tsx?)$/,
use: employCache([
{
loader: 'babel-loader',
options: { babelrc: false, ...babelConfig },
},
]),
exclude: [/node_modules/, /packages(\/|\\)react-datepicker/],
},
{
test: /\.scss$/,
use: employCache([
{
loader: 'style-loader',
options: { injectType: 'lazySingletonStyleTag' },
},
'css-loader',
'postcss-loader',
'sass-loader',
]),
exclude: /node_modules/,
},
{
test: /\.css$/,
use: employCache(['style-loader', 'css-loader']),
exclude: /node_modules/,
},
{
test: /\.(woff|woff2|ttf|eot|ico)(\?|$)/,
type: 'asset/resource',
},
{
test: /\.(png|jp(e*)g|svg|gif)$/,
type: 'asset',
generator: {
filename: 'images/[contenthash]-[name].[ext]',
{
test: /\.(js|tsx?)$/,
use: employCache([
{
loader: 'babel-loader',
options: { babelrc: false, ...babelConfig },
},
parser: {
dataUrlCondition: {
maxSize: 8 * 1024,
},
]),
exclude: [/node_modules/, /packages(\/|\\)react-datepicker/],
},
{
test: /\.scss$/,
use: employCache([
{
loader: 'style-loader',
options: { injectType: 'lazySingletonStyleTag' },
},
},
],
},

plugins: [
new HtmlWebpackPlugin({
template: 'index.html',
inject: 'body',
cache: true,
showErrors: true,
}),

new CircularDependencyPlugin({
'css-loader',
'postcss-loader',
'sass-loader',
]),
exclude: /node_modules/,
failOnError: true,
}),

new NodePolyfillPlugin(),
// run TypeScript during webpack build
// new ForkTsCheckerWebpackPlugin({
// typescript: { configFile: path.resolve(__dirname, '..', 'tsconfig.json') },
// async: false, // makes errors more visible, but potentially less performant
// }),
],

devServer: isDevelopment
? {
static: {
directory: path.resolve(__dirname, 'build'),
// prevent file watching while running on CI
// /app/ represents the entire docker environment
watch: isPuppeteer ? { ignored: '**/*' } : undefined,
},
{
test: /\.css$/,
use: employCache(['style-loader', 'css-loader']),
exclude: /node_modules/,
},
{
test: /\.(woff|woff2|ttf|eot|ico)(\?|$)/,
type: 'asset/resource',
},
{
test: /\.(png|jp(e*)g|svg|gif)$/,
type: 'asset',
generator: {
filename: 'images/[contenthash]-[name].[ext]',
},
parser: {
dataUrlCondition: {
maxSize: 8 * 1024,
},
host: '0.0.0.0',
port,
allowedHosts: 'all',
historyApiFallback: true,
}
: undefined,
};
},
},
],
},

plugins: [
new HtmlWebpackPlugin({
template: 'index.html',
inject: 'body',
cache: true,
showErrors: true,
}),

new CircularDependencyPlugin({
exclude: /node_modules/,
failOnError: true,
}),

new NodePolyfillPlugin(),
// run TypeScript during webpack build
// new ForkTsCheckerWebpackPlugin({
// typescript: { configFile: path.resolve(__dirname, '..', 'tsconfig.json') },
// async: false, // makes errors more visible, but potentially less performant
// }),
],

devServer: isDevelopment
? {
static: {
directory: path.resolve(__dirname, 'build'),
// prevent file watching while running on CI
// /app/ represents the entire docker environment
watch: isPuppeteer ? { ignored: '**/*' } : undefined,
},
host: '0.0.0.0',
port: 8030,
allowedHosts: 'all',
historyApiFallback: true,
}
: undefined,
};

module.exports = webpackConfig;

0 comments on commit a3ff60f

Please sign in to comment.