-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from glook/webpack5
Version 1.0.0 * moved to webpack 5 (YAY) * added and configured copyPlugin * replaced file-loader to build in asset manager * removed unused dependencies (lodash, thread-loader,file-loader) * dependencies was updated to latest version * reorganised structure of config files
- Loading branch information
Showing
51 changed files
with
710 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,13 @@ | |
* Created by: Andrey Polyakov ([email protected]) | ||
*/ | ||
const {argv} = require('yargs'); | ||
const get = require('lodash/get'); | ||
|
||
module.exports = (api) => { | ||
const mode = argv ? get(argv, 'env.mode', 'production') : 'production'; | ||
const env = argv.env || []; | ||
const mode = !!env.find((value) => value === 'mode=dev') | ||
? 'development' | ||
: 'production'; | ||
|
||
// This caches the Babel config by environment. | ||
api.cache.using(() => mode); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
node_modules | ||
dist | ||
webpack | ||
.eslintrc.js | ||
webpack.config.babel.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
.idea | ||
.vscode | ||
dist | ||
node_modules | ||
package-lock.json | ||
yarn.lock | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
{ | ||
"name": "webpack-typescript-react", | ||
"version": "0.0.9", | ||
"description": "", | ||
"license": "ISC", | ||
"author": "", | ||
"main": "index.js", | ||
"version": "1.0.0", | ||
"description": "Webpack 5 boilerplate with support of most common loaders and modules", | ||
"keywords": [ | ||
"react", | ||
"typescript", | ||
"webpack", | ||
"webpack 5", | ||
"webpack boilerplate" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "[email protected]:glook/webpack-typescript-react.git" | ||
}, | ||
"license": "MIT", | ||
"author": "Andrey Polyakov <[email protected]>", | ||
"main": "webpack.config.babel.js", | ||
"scripts": { | ||
"build": "webpack --env.mode production", | ||
"start": "webpack-dev-server --env.mode dev --env.isDevServer true" | ||
"build": "webpack --config webpack.config.babel.js", | ||
"profile": "webpack --profile --json --config webpack.config.babel.js > ./dist/profile.json && webpack-bundle-analyzer ./dist/profile.json", | ||
"start": "webpack --env mode=dev --env isDevServer --env NODE_ENV=local serve --config webpack.config.babel.js" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
|
@@ -17,87 +29,81 @@ | |
}, | ||
"dependencies": { | ||
"@types/classnames": "^2.2.10", | ||
"@types/react": "^16.9.51", | ||
"@types/react": "^16.9.53", | ||
"@types/react-dom": "^16.9.8", | ||
"classnames": "^2.2.6", | ||
"normalize.css": "^8.0.1", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1" | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.11.6", | ||
"@babel/plugin-proposal-class-properties": "^7.10.4", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.10.4", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.11.0", | ||
"@babel/plugin-proposal-throw-expressions": "^7.10.4", | ||
"@babel/plugin-syntax-dynamic-import": "^7.8.3", | ||
"@babel/plugin-transform-runtime": "^7.11.5", | ||
"@babel/preset-env": "^7.11.5", | ||
"@babel/preset-react": "^7.10.4", | ||
"@babel/register": "^7.11.5", | ||
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.2", | ||
"@svgr/webpack": "^5.4.0", | ||
"@teamsupercell/typings-for-css-modules-loader": "^2.3.0", | ||
"@typescript-eslint/eslint-plugin": "^4.4.0", | ||
"@typescript-eslint/parser": "^4.4.0", | ||
"autoprefixer": "^9.8.6", | ||
"babel-eslint": "^10.1.0", | ||
"babel-loader": "^8.1.0", | ||
"clean-webpack-plugin": "^3.0.0", | ||
"copy-webpack-plugin": "^6.2.0", | ||
"core-js": "^3.6.5", | ||
"css-loader": "4.3.0", | ||
"cssnano": "^4.1.10", | ||
"eslint": "^7.10.0", | ||
"eslint-config-airbnb-base": "^14.2.0", | ||
"eslint-config-airbnb-typescript": "^11.0.0", | ||
"eslint-config-prettier": "^6.12.0", | ||
"eslint-import-resolver-alias": "^1.1.2", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jsx-a11y": "^6.3.1", | ||
"eslint-plugin-react": "^7.21.3", | ||
"eslint-plugin-react-hooks": "^4.1.2", | ||
"eslint-webpack-plugin": "^2.1.0", | ||
"expose-loader": "1.0.0", | ||
"extract-text-webpack-plugin": "^4.0.0-beta.0", | ||
"file-loader": "6.1.0", | ||
"fork-ts-checker-webpack-plugin": "^5.2.0", | ||
"html-loader": "^1.3.1", | ||
"html-webpack-plugin": "^4.5.0", | ||
"husky": "^4.3.0", | ||
"import-sort-style-module-and-prefix": "^0.1.3", | ||
"is-windows": "^1.0.2", | ||
"less": "^3.12.2", | ||
"less-loader": "^7.0.1", | ||
"lint-staged": "^10.4.0", | ||
"lodash": "^4.17.20", | ||
"mini-css-extract-plugin": "^0.11.3", | ||
"path": "^0.12.7", | ||
"postcss-loader": "4.0.3", | ||
"prettier": "^2.1.2", | ||
"prettier-plugin-import-sort": "0.0.6", | ||
"pretty-quick": "^3.0.2", | ||
"react-refresh": "^0.8.3", | ||
"regenerator-runtime": "^0.13.7", | ||
"resolve-url-loader": "^3.1.1", | ||
"sass": "^1.27.0", | ||
"sass-loader": "^10.0.2", | ||
"sass-resources-loader": "^2.1.1", | ||
"speed-measure-webpack-plugin": "^1.3.3", | ||
"style-loader": "1.3.0", | ||
"svg-url-loader": "^6.0.0", | ||
"terser-webpack-plugin": "^4.2.2", | ||
"thread-loader": "^3.0.0", | ||
"ts-loader": "^8.0.4", | ||
"typescript": "^4.0.3", | ||
"url-loader": "4.1.0", | ||
"webpack": "^4.44.2", | ||
"webpack-cli": "^3.3.12", | ||
"webpack-dev-server": "^3.11.0", | ||
"webpack-merge": "5.1.4", | ||
"webpack-serve": "^3.2.0", | ||
"webpack-stats-plugin": "0.3.2", | ||
"yargs": "^16.0.3" | ||
"@babel/core": "~7.12.3", | ||
"@babel/plugin-proposal-class-properties": "~7.12.1", | ||
"@babel/plugin-proposal-export-default-from": "^7.12.1", | ||
"@babel/plugin-proposal-export-namespace-from": "~7.12.1", | ||
"@babel/plugin-proposal-object-rest-spread": "~7.12.1", | ||
"@babel/plugin-proposal-throw-expressions": "~7.12.1", | ||
"@babel/plugin-syntax-dynamic-import": "~7.8.3", | ||
"@babel/plugin-transform-runtime": "~7.12.1", | ||
"@babel/preset-env": "~7.12.1", | ||
"@babel/preset-react": "~7.12.1", | ||
"@babel/register": "~7.12.1", | ||
"@pmmmwh/react-refresh-webpack-plugin": "~0.4.2", | ||
"@svgr/webpack": "~5.4.0", | ||
"@teamsupercell/typings-for-css-modules-loader": "~2.3.0", | ||
"@typescript-eslint/eslint-plugin": "~4.6.0", | ||
"@typescript-eslint/parser": "~4.6.0", | ||
"autoprefixer": "~10.0.1", | ||
"babel-eslint": "~10.1.0", | ||
"babel-loader": "~8.1.0", | ||
"clean-webpack-plugin": "~3.0.0", | ||
"copy-webpack-plugin": "~6.2.1", | ||
"core-js": "~3.6.5", | ||
"css-loader": "~5.0.0", | ||
"cssnano": "~4.1.10", | ||
"eslint": "~7.12.0", | ||
"eslint-config-airbnb-base": "~14.2.0", | ||
"eslint-config-airbnb-typescript": "~12.0.0", | ||
"eslint-config-prettier": "~6.14.0", | ||
"eslint-import-resolver-alias": "~1.1.2", | ||
"eslint-plugin-import": "~2.22.1", | ||
"eslint-plugin-jsx-a11y": "~6.4.1", | ||
"eslint-plugin-react": "~7.21.5", | ||
"eslint-plugin-react-hooks": "~4.2.0", | ||
"eslint-webpack-plugin": "~2.1.0", | ||
"fork-ts-checker-webpack-plugin": "~5.2.0", | ||
"html-loader": "~1.3.2", | ||
"html-webpack-plugin": "~5.0.0-alpha.6", | ||
"husky": "~4.3.0", | ||
"import-sort-style-module-and-prefix": "~0.1.3", | ||
"is-windows": "~1.0.2", | ||
"less": "~3.12.2", | ||
"less-loader": "~7.0.2", | ||
"lint-staged": "~10.5.0", | ||
"mini-css-extract-plugin": "~1.2.0", | ||
"path": "~0.12.7", | ||
"postcss-loader": "~4.0.4", | ||
"prettier": "~2.1.2", | ||
"prettier-plugin-import-sort": "~0.0.6", | ||
"pretty-quick": "~3.1.0", | ||
"react-refresh": "~0.9.0", | ||
"regenerator-runtime": "~0.13.7", | ||
"resolve-url-loader": "~3.1.2", | ||
"sass": "~1.27.0", | ||
"sass-loader": "~10.0.4", | ||
"sass-resources-loader": "~2.1.1", | ||
"style-loader": "~2.0.0", | ||
"svg-url-loader": "~6.0.0", | ||
"terser-webpack-plugin": "~5.0.1", | ||
"ts-loader": "~8.0.7", | ||
"typescript": "~4.0.3", | ||
"url-loader": "~4.1.1", | ||
"webpack": "~5.2.0", | ||
"webpack-bundle-analyzer": "~3.9.0", | ||
"webpack-cli": "~4.1.0", | ||
"webpack-dev-server": "~3.11.0", | ||
"webpack-merge": "~5.2.0", | ||
"yargs": "~16.1.0" | ||
}, | ||
"importSort": { | ||
".ts, .tsx": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
declare module '*.scss' { | ||
const content: { [className: string]: string }; | ||
export = content; | ||
declare module "*.scss" { | ||
const content: { [className: string]: string }; | ||
export = content; | ||
} | ||
|
||
declare module '*.less' { | ||
const content: { [className: string]: string }; | ||
export = content; | ||
declare module "*.less" { | ||
const content: { [className: string]: string }; | ||
export = content; | ||
} | ||
|
||
declare module '*.component.svg' { | ||
const content: any; | ||
export default content; | ||
declare module "*.svg" { | ||
import React = require("react"); | ||
const ReactComponent: React.FunctionComponent<React.SVGProps<SVGSVGElement>>; | ||
export default ReactComponent; | ||
} | ||
|
||
declare const IS_PROD: boolean; | ||
declare const IS_DEV: boolean; | ||
declare const IS_DEV_SERVER: boolean; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
/** | ||
* Created by: Andrey Polyakov ([email protected]) | ||
*/ | ||
import 'core-js/stable'; | ||
import 'regenerator-runtime/runtime'; | ||
|
||
import '@styles/styles.less'; | ||
import '@styles/styles.scss'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Created by: Andrey Polyakov ([email protected]) | ||
* @see https://webpack.js.org/configuration/dev-server/ | ||
*/ | ||
import {join} from 'path'; | ||
|
||
import {rootDir} from '../utils/env'; | ||
|
||
export const aliasItems = { | ||
'@src': join(rootDir, '/src'), | ||
'@images': join(rootDir, '/src/images'), | ||
'@styles': join(rootDir, '/src/styles'), | ||
'@components': join(rootDir, '/src/components'), | ||
}; |
Oops, something went wrong.