improved webpack
This commit is contained in:
parent
2d8d3c99f1
commit
ce4b0032e2
11
.babelrc
11
.babelrc
@ -1,7 +1,14 @@
|
|||||||
{
|
{
|
||||||
"presets": [
|
"presets": [
|
||||||
["@babel/preset-env", { "modules": false }],
|
["@babel/preset-env",
|
||||||
|
{
|
||||||
|
"targets":
|
||||||
|
{
|
||||||
|
"node": "14"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"@babel/preset-react"
|
"@babel/preset-react"
|
||||||
],
|
],
|
||||||
"plugins": ["react-hot-loader/babel"]
|
"plugins": ["@babel/plugin-proposal-class-properties"]
|
||||||
}
|
}
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -16,3 +16,6 @@ yarn-error.log*
|
|||||||
|
|
||||||
componentName.json
|
componentName.json
|
||||||
localName.json
|
localName.json
|
||||||
|
|
||||||
|
yarn.lock
|
||||||
|
package-lock.json
|
8760
package-lock.json
generated
Normal file
8760
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack",
|
"build": "webpack",
|
||||||
"dev": "NODE_ENV=development webpack serve",
|
"dev": "NODE_ENV=development webpack serve",
|
||||||
|
"wdev": "set NODE_ENV=development && webpack serve",
|
||||||
"lint": "eslint --config .eslintrc",
|
"lint": "eslint --config .eslintrc",
|
||||||
"format": "prettier --write \"src/**/*.+(js|ts|jsx|tsx|json|css|md)\""
|
"format": "prettier --write \"src/**/*.+(js|ts|jsx|tsx|json|css|md)\""
|
||||||
},
|
},
|
||||||
@ -16,11 +17,13 @@
|
|||||||
"@babel/core": "^7.12.10",
|
"@babel/core": "^7.12.10",
|
||||||
"@babel/preset-env": "^7.12.10",
|
"@babel/preset-env": "^7.12.10",
|
||||||
"@babel/preset-react": "^7.12.10",
|
"@babel/preset-react": "^7.12.10",
|
||||||
|
"@babel/plugin-proposal-class-properties": "^7.12.1",
|
||||||
"@types/node": "^14.14.12",
|
"@types/node": "^14.14.12",
|
||||||
"@types/react": "^15.0.0 || ^16.0.0 || ^17.0.0 ",
|
"@types/react": "^15.0.0 || ^16.0.0 || ^17.0.0 ",
|
||||||
"@types/react-dom": "^17.0.0",
|
"@types/react-dom": "^17.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.9.1",
|
"@typescript-eslint/eslint-plugin": "^4.9.1",
|
||||||
"@typescript-eslint/parser": "^4.9.1",
|
"@typescript-eslint/parser": "^4.9.1",
|
||||||
|
"babel-loader": "^8.2.0",
|
||||||
"css-loader": "^5.0.1",
|
"css-loader": "^5.0.1",
|
||||||
"eslint": "^7.15.0",
|
"eslint": "^7.15.0",
|
||||||
"eslint-config-prettier": "^7.0.0",
|
"eslint-config-prettier": "^7.0.0",
|
||||||
|
@ -3,7 +3,7 @@ const fs = require("fs");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const getGeneratorDataPath = generatorIdentifier =>
|
const getGeneratorDataPath = generatorIdentifier =>
|
||||||
path.resolve(__dirname, `meta/${generatorIdentifier}.json`);
|
path.resolve(__dirname, `${generatorIdentifier}.json`);
|
||||||
|
|
||||||
const getGeneratorData = generatorIdentifier => {
|
const getGeneratorData = generatorIdentifier => {
|
||||||
const path = getGeneratorDataPath(generatorIdentifier);
|
const path = getGeneratorDataPath(generatorIdentifier);
|
||||||
|
@ -8,10 +8,28 @@ const getScopedName = require("./utils/getScopedName.js");
|
|||||||
|
|
||||||
const isDev = process.env.NODE_ENV === "development";
|
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 = {
|
module.exports = {
|
||||||
entry: "./src/index.tsx",
|
entry: "./src/index.tsx",
|
||||||
target: "web",
|
target: "web",
|
||||||
devtool: "inline-source-map",
|
devtool: isDev ? "inline-source-map" : undefined,
|
||||||
mode: "development",
|
mode: "development",
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
@ -20,6 +38,13 @@ module.exports = {
|
|||||||
use: "ts-loader",
|
use: "ts-loader",
|
||||||
include: path.resolve(__dirname, "src"),
|
include: path.resolve(__dirname, "src"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test:/\.js$/,
|
||||||
|
include: /src/,
|
||||||
|
use:{
|
||||||
|
loader:"babel-loader"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
use: [
|
use: [
|
||||||
@ -50,6 +75,9 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
optimization: {
|
||||||
|
minimize: true,
|
||||||
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: [".tsx", ".ts", ".js"],
|
extensions: [".tsx", ".ts", ".js"],
|
||||||
},
|
},
|
||||||
@ -62,13 +90,7 @@ module.exports = {
|
|||||||
compress: true,
|
compress: true,
|
||||||
port: 3000,
|
port: 3000,
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins,
|
||||||
new ESLintPlugin(),
|
|
||||||
new webpack.ProgressPlugin(),
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
template: path.join(__dirname, "public", "index.html"),
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
stats: {
|
stats: {
|
||||||
reasons: true,
|
reasons: true,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user