improved webpack

This commit is contained in:
TUTOR03 2020-12-12 17:41:33 +05:00
parent 2d8d3c99f1
commit ce4b0032e2
6 changed files with 8807 additions and 12 deletions

View File

@ -1,7 +1,14 @@
{
"presets": [
["@babel/preset-env", { "modules": false }],
["@babel/preset-env",
{
"targets":
{
"node": "14"
}
}
],
"@babel/preset-react"
],
"plugins": ["react-hot-loader/babel"]
"plugins": ["@babel/plugin-proposal-class-properties"]
}

3
.gitignore vendored
View File

@ -16,3 +16,6 @@ yarn-error.log*
componentName.json
localName.json
yarn.lock
package-lock.json

8760
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@
"scripts": {
"build": "webpack",
"dev": "NODE_ENV=development webpack serve",
"wdev": "set NODE_ENV=development && webpack serve",
"lint": "eslint --config .eslintrc",
"format": "prettier --write \"src/**/*.+(js|ts|jsx|tsx|json|css|md)\""
},
@ -16,11 +17,13 @@
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.10",
"@babel/preset-react": "^7.12.10",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@types/node": "^14.14.12",
"@types/react": "^15.0.0 || ^16.0.0 || ^17.0.0 ",
"@types/react-dom": "^17.0.0",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"babel-loader": "^8.2.0",
"css-loader": "^5.0.1",
"eslint": "^7.15.0",
"eslint-config-prettier": "^7.0.0",

View File

@ -3,7 +3,7 @@ const fs = require("fs");
const path = require("path");
const getGeneratorDataPath = generatorIdentifier =>
path.resolve(__dirname, `meta/${generatorIdentifier}.json`);
path.resolve(__dirname, `${generatorIdentifier}.json`);
const getGeneratorData = generatorIdentifier => {
const path = getGeneratorDataPath(generatorIdentifier);

View File

@ -8,10 +8,28 @@ const getScopedName = require("./utils/getScopedName.js");
const isDev = process.env.NODE_ENV === "development";
const plugins = [
new webpack.ProgressPlugin(),
new HtmlWebpackPlugin({
template: path.join(__dirname, "public", "index.html"),
}),
]
if (!isDev)
{
plugins.push(
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})
)
}
module.exports = {
entry: "./src/index.tsx",
target: "web",
devtool: "inline-source-map",
devtool: isDev ? "inline-source-map" : undefined,
mode: "development",
module: {
rules: [
@ -20,6 +38,13 @@ module.exports = {
use: "ts-loader",
include: path.resolve(__dirname, "src"),
},
{
test:/\.js$/,
include: /src/,
use:{
loader:"babel-loader"
}
},
{
test: /\.css$/,
use: [
@ -50,6 +75,9 @@ module.exports = {
},
],
},
optimization: {
minimize: true,
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
@ -62,13 +90,7 @@ module.exports = {
compress: true,
port: 3000,
},
plugins: [
new ESLintPlugin(),
new webpack.ProgressPlugin(),
new HtmlWebpackPlugin({
template: path.join(__dirname, "public", "index.html"),
}),
],
plugins,
stats: {
reasons: true,
},