Skip to content

Commit 50eee12

Browse files
committed
* Update dependencies to latest version
* Added webpack folder to .eslintignore * Added external section to webpack config * Added verifyOnly parameter to typingsCssModulesLoader
1 parent 8afa617 commit 50eee12

File tree

9 files changed

+43
-43
lines changed

9 files changed

+43
-43
lines changed

Diff for: .babelrc.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
* Created by: Andrey Polyakov ([email protected])
33
*/
44
const {argv} = require('yargs');
5+
const get = require('lodash/get');
6+
57
module.exports = (api) => {
6-
const {env} = argv;
7-
const mode = env.mode ? env.mode : 'production';
8+
const mode = argv ? get(argv, 'env.mode', 'production') : 'production';
89
// This caches the Babel config by environment.
910
api.cache.using(() => mode);
11+
1012
return {
1113
presets: [
1214
[

Diff for: .eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
dist
3+
webpack

Diff for: package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack-typescript-react",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"description": "",
55
"license": "ISC",
66
"author": "",
@@ -17,7 +17,7 @@
1717
},
1818
"dependencies": {
1919
"@types/classnames": "^2.2.10",
20-
"@types/react": "^16.9.45",
20+
"@types/react": "^16.9.46",
2121
"@types/react-dom": "^16.9.8",
2222
"classnames": "^2.2.6",
2323
"normalize.css": "^8.0.1",
@@ -38,8 +38,8 @@
3838
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.1",
3939
"@svgr/webpack": "^5.4.0",
4040
"@teamsupercell/typings-for-css-modules-loader": "^2.2.1",
41-
"@typescript-eslint/eslint-plugin": "^3.8.0",
42-
"@typescript-eslint/parser": "^3.8.0",
41+
"@typescript-eslint/eslint-plugin": "^3.9.0",
42+
"@typescript-eslint/parser": "^3.9.0",
4343
"autoprefixer": "^9.8.6",
4444
"babel-eslint": "^10.1.0",
4545
"babel-loader": "^8.1.0",
@@ -48,15 +48,15 @@
4848
"core-js": "^3.6.5",
4949
"css-loader": "4.2.1",
5050
"cssnano": "^4.1.10",
51-
"eslint": "^7.6.0",
51+
"eslint": "^7.7.0",
5252
"eslint-config-airbnb-base": "^14.2.0",
5353
"eslint-config-airbnb-typescript": "^9.0.0",
5454
"eslint-config-prettier": "^6.11.0",
5555
"eslint-import-resolver-alias": "^1.1.2",
5656
"eslint-loader": "^4.0.2",
5757
"eslint-plugin-import": "^2.22.0",
5858
"eslint-plugin-jsx-a11y": "^6.3.1",
59-
"eslint-plugin-react": "^7.20.5",
59+
"eslint-plugin-react": "^7.20.6",
6060
"eslint-plugin-react-hooks": "^4.0.8",
6161
"expose-loader": "1.0.0",
6262
"extract-text-webpack-plugin": "^4.0.0-beta.0",
@@ -70,8 +70,8 @@
7070
"less": "^3.12.2",
7171
"less-loader": "^6.2.0",
7272
"lint-staged": "^10.2.11",
73-
"lodash": "^4.17.19",
74-
"mini-css-extract-plugin": "^0.9.0",
73+
"lodash": "^4.17.20",
74+
"mini-css-extract-plugin": "^0.10.0",
7575
"node-sass": "4.14.1",
7676
"path": "^0.12.7",
7777
"postcss-loader": "3.0.0",
@@ -85,7 +85,7 @@
8585
"sass-resources-loader": "^2.0.3",
8686
"style-loader": "1.2.1",
8787
"svg-url-loader": "^6.0.0",
88-
"terser-webpack-plugin": "^4.0.0",
88+
"terser-webpack-plugin": "^4.1.0",
8989
"thread-loader": "^2.1.3",
9090
"ts-loader": "^8.0.2",
9191
"typescript": "^3.9.7",

Diff for: webpack.config.babel.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import merge from 'webpack-merge';
55

66
import baseConfig from './webpack/base';
77
import devConfig from './webpack/dev';
8-
import env from './webpack/env';
8+
import {isProd} from './webpack/env';
99
import prodConfig from './webpack/prod';
1010

11-
const {isProd} = env;
12-
1311
export default () =>
1412
isProd ? merge(baseConfig, prodConfig) : merge(baseConfig, devConfig);

Diff for: webpack/base.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@ import path from 'path';
55

66
import {devServerUrl} from './constants/devproxy';
77
import entry from './entry';
8-
import env from './env';
8+
import {isDevServer, isProd} from './env';
99
import rules from './loaders';
1010
import optimization from './optimization';
1111
import plugins from './plugins';
12+
import externals from './resources/externals';
1213
import resolve from './resources/resolve';
1314

1415
export default {
1516
context: __dirname,
1617
target: 'web',
17-
mode: env.isProd ? 'production' : 'development',
18+
mode: isProd ? 'production' : 'development',
1819
entry,
1920
output: {
2021
path: path.join(__dirname, '../dist'),
21-
publicPath: env.isDevServer ? devServerUrl : './',
22-
filename: env.isDevServer
23-
? '[name].[hash].js'
24-
: '[name].[contenthash].js',
22+
publicPath: isDevServer ? devServerUrl : './',
23+
filename: isDevServer ? '[name].[hash].js' : '[name].[contenthash].js',
2524
},
2625
module: {
2726
rules,
2827
},
2928
plugins,
3029
resolve,
3130
optimization,
31+
externals,
3232
};

Diff for: webpack/constants/loadersList.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import {resolve} from 'path';
2-
31
/**
42
* Created by: Andrey Polyakov ([email protected])
53
*/
4+
import {resolve} from 'path';
5+
66
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
77

8-
import env from '../env';
8+
import {isDev, isDevServer, isProd} from '../env';
99
import resources from '../resources/sassResources';
1010

1111
export const cssLoader = {
1212
loader: 'css-loader',
1313
options: {
14-
sourceMap: env.isProd,
14+
sourceMap: isProd,
1515
},
1616
};
1717

1818
export const cssModulesLoader = {
1919
...cssLoader,
2020
options: {
21-
sourceMap: env.isDev,
21+
sourceMap: isDev,
2222
modules: {
2323
exportLocalsConvention: 'camelCaseOnly',
2424
localIdentName: '[local]__[hash:base64:5]',
@@ -49,15 +49,15 @@ export const postCssLoader = {
4949
config: {
5050
path: __dirname,
5151
},
52-
sourceMap: env.isProd,
52+
sourceMap: isProd,
5353
},
5454
};
5555

56-
export const miniCssExtractLoader = env.isProd
56+
export const miniCssExtractLoader = isProd
5757
? {
5858
loader: MiniCssExtractPlugin.loader,
5959
options: {
60-
hmr: env.isDevServer,
60+
hmr: isDevServer,
6161
},
6262
}
6363
: 'style-loader';

Diff for: webpack/env.js

+4-11
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@
44
import get from 'lodash/get';
55
import {argv} from 'yargs';
66

7-
const mode = get(argv, 'env.mode', 'production');
8-
const isDevServer = get(argv, 'env.isDevServer', false);
9-
const isProd = mode === 'production';
10-
const isDev = !isProd;
11-
12-
export default {
13-
mode,
14-
isDevServer,
15-
isProd,
16-
isDev,
17-
};
7+
export const mode = get(argv, 'env.mode', 'production');
8+
export const isDevServer = get(argv, 'env.isDevServer', false);
9+
export const isProd = mode === 'production';
10+
export const isDev = !isProd;

Diff for: webpack/plugins.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import HtmlWebpackPlugin from 'html-webpack-plugin';
99
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
1010
import {DefinePlugin, ProvidePlugin} from 'webpack';
1111

12-
import env from './env';
12+
import {isDev} from './env';
1313
import defineList from './resources/define';
1414
import htmlPluginConfg from './resources/html';
1515
import provideList from './resources/provide';
@@ -18,15 +18,15 @@ export default [
1818
new MiniCssExtractPlugin({
1919
// Options similar to the same options in webpackOptions.output
2020
// both options are optional
21-
filename: env.isDev ? '[name].css' : '[name].[contenthash].css',
22-
chunkFilename: env.isDev ? '[id].css' : '[id].[contenthash].css',
21+
filename: isDev ? '[name].css' : '[name].[contenthash].css',
22+
chunkFilename: isDev ? '[id].css' : '[id].[contenthash].css',
2323
}),
2424
new HtmlWebpackPlugin(htmlPluginConfg),
2525
new ProvidePlugin(provideList),
2626
new DefinePlugin(defineList),
2727
new CleanWebpackPlugin(),
2828
new ForkTsCheckerWebpackPlugin({
29-
async: env.isDev,
29+
async: isDev,
3030
typescript: {
3131
configFile: resolve(__dirname, '../tsconfig.json'),
3232
},

Diff for: webpack/resources/externals.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Created by: Andrey Polyakov ([email protected])
3+
*/
4+
export default {
5+
// jquery: 'jQuery'
6+
};

0 commit comments

Comments
 (0)