Skip to content

Commit

Permalink
fix(webpack) Update webpack version to v5
Browse files Browse the repository at this point in the history
Signed-off-by: Siye Wang <[email protected]>
  • Loading branch information
smallteeths committed Jul 27, 2022
1 parent 6b85069 commit 23b85ef
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 134 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM node:16 as builder
RUN apt-get update -y && \
apt-get install -y gettext-base
RUN npm install --location=global [email protected]
RUN mkdir /web
WORKDIR /web
COPY . /web
Expand Down
48 changes: 23 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "webpack-dev-server --config=webpack.config.development.js --mode development",
"dev": "webpack serve --config=webpack.config.development.js --mode development",
"build": "cross-env NODE_ENV=production webpack --config=webpack.config.production.js --mode production",
"lint": "eslint --ext .js src",
"precommit": "npm run lint",
Expand Down Expand Up @@ -58,23 +58,22 @@
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@webassemblyjs/ast": "^1.3.1",
"@webassemblyjs/wasm-edit": "^1.3.1",
"acorn": "^6.1.1",
"add-asset-html-webpack-plugin": "^3.1.3",
"address": "^1.0.3",
"babel-eslint": "^8.2.3",
"babel-loader": "^8.0.0",
"babel-loader": "^8.2.5",
"babel-plugin-dva-hmr": "^0.4.1",
"babel-plugin-import": "^1.7.0",
"babel-plugin-transform-remove-console": "^6.9.2",
"body-parser": "^1.18.3",
"clean-webpack-plugin": "^0.1.19",
"copy-webpack-plugin": "^4.5.1",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^11.0.0",
"cross-env": "^5.1.1",
"cross-port-killer": "^1.0.1",
"css-hot-loader": "^1.4.4",
"css-loader": "^2.1.1",
"css-loader": "^6.7.1",
"css-minimizer-webpack-plugin": "^4.0.0",
"cssnano": "^4.1.10",
"es5-imcompatible-versions": "^0.1.34",
"eslint": "^5.16.0",
Expand All @@ -85,38 +84,37 @@
"eslint-plugin-react": "^7.7.0",
"estraverse": "^4.2.0",
"expect": "^1.20.2",
"file-loader": "^1.1.11",
"friendly-errors-webpack-plugin": "^1.7.0",
"file-loader": "^6.2.0",
"happypack": "^5.0.0-beta.4",
"html-webpack-plugin": "^3.2.0",
"html-webpack-plugin": "^5.5.0",
"husky": "^1.0.0-rc.4",
"jest": "^26.1.0",
"keymaster": "^1.6.2",
"less": "3.0.4",
"less-loader": "^4.1.0",
"mini-css-extract-plugin": "^0.4.0",
"less": "^3.0.4",
"less-loader": "^11.0.0",
"mini-css-extract-plugin": "^2.6.1",
"mockjs": "^1.0.1-beta3",
"open-browser-webpack-plugin": "0.0.5",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"open-browser-webpack-plugin": "^0.0.5",
"path-browserify": "^1.0.1",
"pre-commit": "^1.2.2",
"pro-download": "^1.0.1",
"progress-bar-webpack-plugin": "^1.12.1",
"progress-bar-webpack-plugin": "^2.1.0",
"redbox-react": "^1.5.0",
"redux-devtools": "^3.4.1",
"redux-devtools-dock-monitor": "^1.1.3",
"redux-devtools-log-monitor": "^1.4.0",
"regenerator-runtime": "^0.11.1",
"sass-loader": "^7.0.1",
"sass-loader": "^13.0.2",
"serve-index": "^1.9.1",
"string-replace-loader": "^2.1.1",
"style-loader": "^0.21.0",
"string-replace-loader": "^3.1.0",
"style-loader": "^3.3.1",
"type-is": "^1.6.15",
"uglifyjs-webpack-plugin": "^1.2.5",
"url-loader": "^1.0.1",
"webpack": "^4.33.0",
"webpack-cli": "^3.1.1",
"webpack-dev-server": "^3.1.4",
"webpack-manifest-plugin": "^2.0.4"
"url": "^0.11.0",
"url-loader": "^4.1.1",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.9.3",
"webpack-manifest-plugin": "^5.0.0"
},
"pre-commit": [
"precommit"
Expand Down
117 changes: 53 additions & 64 deletions webpack.config.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,34 @@
const webpack = require("webpack");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const ManifestPlugin = require("webpack-manifest-plugin");
const theme = require("./src/theme");
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const OpenBrowserPlugin = require('open-browser-webpack-plugin');
var FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const endpoint = process.env.LONGHORN_MANAGER_IP || 'http://54.223.25.181:9500/';


module.exports = {
entry: path.resolve(__dirname, "src", "index.js"),
devServer: {
// contentBase: path.resolve(__dirname, 'dist'),
host: "0.0.0.0",
host: "localhost",
port: 8080,
open: false,
open: true,
hot: true,
quiet: true,
disableHostCheck: true,
historyApiFallback: true,
overlay: {
errors: true
client: {
overlay: true,
},
stats: {
children: false,
chunks: false,
assets: false,
modules: false
devMiddleware: {
stats: {
children: false,
chunks: false,
assets: false,
modules: false
},
},
proxy: {
proxyTimeout: 10 * 60 * 1000,
Expand Down Expand Up @@ -63,86 +61,75 @@ module.exports = {
services: path.resolve(__dirname, "src/services/"),
routes: path.resolve(__dirname, "src/routes/"),
models: path.resolve(__dirname, "src/models/")
}
},
fallback: {
path: require.resolve( 'path-browserify' ),
url: require.resolve('url')
},
},
module: {
rules: [
{
test: /\.js$/,
include: [path.resolve(__dirname, "src")],
exclude: [],
loader: "babel-loader?cacheDirectory",
},
{
test: /\.css$/,
use: [
{
loader: "css-loader",
options: {
importLoaders: 1
}
}
]
loader: "babel-loader",
options: {
cacheDirectory: true,
}
},
{
test: /\.less$/,
test:/\.(c|le)ss$/i,
use: [
'css-hot-loader',
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: true,
// if hmr does not work, this is a forceful method.
reloadAll: true,
modifyVars: theme()
},
},
{
loader: "css-loader",
options: {
sourceMap: true,
importLoaders: 1,
modules: true,
localIdentName: "[name]_[local]-[hash:base64:5]"
modules: {
namedExport: false,
localIdentName: "[name]_[local]-[hash:base64:5]"
},
}
},
{
loader: "less-loader",
options: {
sourceMap: true,
javascriptEnabled: true,
modifyVars: theme()
lessOptions: {
javascriptEnabled: true,
modifyVars: theme()
}
}
}
],
exclude: /node_modules/
},
{
test: /\.less$/,
test:/\.(c|le)ss$/i,
use: [
'css-hot-loader',
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: true,
// if hmr does not work, this is a forceful method.
reloadAll: true,
modifyVars: theme()
},
},
{
loader: "css-loader",
options: {
sourceMap: true,
importLoaders: 1
importLoaders: 1,
}
},
{
loader: "less-loader",
options: {
sourceMap: true,
javascriptEnabled: true,
modifyVars: theme()
lessOptions: {
namedExport: true,
javascriptEnabled: true,
modifyVars: theme()
}
}
}
],
Expand All @@ -164,10 +151,6 @@ module.exports = {
externals: {
jquery: "jQuery"
},
node: {
fs: "empty",
module: "empty"
},
devtool: "source-map",
optimization: {
splitChunks: {
Expand All @@ -182,25 +165,31 @@ module.exports = {
}
},
plugins: [
new OpenBrowserPlugin({url: 'http://localhost:8080/'}),
new ProgressBarPlugin(),
new FriendlyErrorsWebpackPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: '[id].css'
chunkFilename: '[id].css',
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src", "index.ejs"),
filename: "index.html",
scriptLoading: "blocking",
inject: "body",
hash: true
}),
new CleanWebpackPlugin(["dist"]),
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, "public")
}
]),
new CleanWebpackPlugin(),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, "public")
},
],
}),
new webpack.HotModuleReplacementPlugin(),
new ManifestPlugin()
new ManifestPlugin.WebpackManifestPlugin()
]
};
Loading

0 comments on commit 23b85ef

Please sign in to comment.