Javascript 网页包3到4升级\uuu网页包\uHMR在加载网页时被中断
我已从第3页升级到第4页。在这次升级过程中,我解决了许多问题,但最终成功构建了Webpack4,但一旦编译,它就会显示“编译时带有警告” 但是,它们看起来都像是弃用警告,没有错误 站点开始在localhost:3333上加载,但在加载未完成时停止。Firefox中的控制台错误状态为: “加载页面时,与的连接被中断。” 然而,我在Chrome中没有发现这个错误,但是该站点也不会一直加载到该浏览器中 两种浏览器都向我提供HMR警告: [HMR]捆绑包有4个警告 ./stores/dynamic requires/components.js 21:0-96 关键依赖项:上下文不能使用带有“g”或“y”标志的正则表达式。 配置 尚未设置“模式”选项,对于此值,webpack将回退到“生产”。将“模式”选项设置为“开发”或“生产”,以启用每个环境的默认设置。 您还可以将其设置为“无”以禁用任何默认行为。了解更多信息: 资产规模限制:以下资产超过建议的规模限制(244千磅)。 这可能会影响web性能。 资产: app.js(1.04 MiB) stickyElements.js(601 KiB) 入口点大小限制:以下入口点组合资产大小超过建议的限制(244千磅)。这可能会影响web性能。 入口点: 粘性元素(601千磅) stickyElements.js 应用程序(1.04 MiB) app.js 这个应用程序最初设置为使用UglifyJS,据我所知,该插件已被删除。我正在将其加载到package.json文件中,并将其作为const放入webpack配置中,并删除了旧的UglifyJS实现“new webpack.optimize.UglifyJsPlugin()”。但我不确定我是否需要做任何其他事情来使用UglifyJS,或者这是否是一个相关的问题。这是我当前的webpack.config.prod.js文件:Javascript 网页包3到4升级\uuu网页包\uHMR在加载网页时被中断,javascript,node.js,webpack,Javascript,Node.js,Webpack,我已从第3页升级到第4页。在这次升级过程中,我解决了许多问题,但最终成功构建了Webpack4,但一旦编译,它就会显示“编译时带有警告” 但是,它们看起来都像是弃用警告,没有错误 站点开始在localhost:3333上加载,但在加载未完成时停止。Firefox中的控制台错误状态为: “加载页面时,与的连接被中断。” 然而,我在Chrome中没有发现这个错误,但是该站点也不会一直加载到该浏览器中 两种浏览器都向我提供HMR警告: [HMR]捆绑包有4个警告 ./stores/dynamic re
const path = require('path');
const webpack = require('webpack');
const WebpackStrip = require('strip-loader');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
mode: "production",
context: path.join(process.env.PWD, 'CLIENTSIDE/JS'),
entry: {
stickyElements: ['babel-polyfill', './components/dest_portal_UI/stickyElements'],
destinationPortalStyles: ['./hot_styles/destinationPortalStyles'],
login_page: ['./hot_styles/login-page'],
app: ['babel-polyfill', './components/index'],
},
output: {
path: path.join(process.env.PWD, 'CLIENTSIDE/static'),
filename: '[name].js',
publicPath: '/static/'
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
// new webpack.optimize.UglifyJsPlugin()
],
node: {fs: 'empty'},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
use: [
{ loader: 'babel-loader',
options: {
cacheDirectory: true,
presets: ['react', 'es2015', 'stage-0'],
plugins: ['transform-decorators-legacy', 'transform-object-assign', 'array-includes']
}
},
{ loader: WebpackStrip.loader('debug', 'console.log') }
],
},
{
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'sass-loader']
}
]
},
resolve: {
extensions: ['.js', '.jsx']
}
};
和package.json
{
"name": "app-name",
"version": "1.0.0",
"private": true,
"scripts": {
"clean": "rimraf ./CLIENTSIDE/static",
"checkYarn": "if brew ls --versions yarn > /dev/null; then echo 'yarn is installed'; else brew install yarn; fi ",
"checkMongo": "if brew ls --versions mongodb-community > /dev/null; then echo 'mongodb-community is installed'; else brew install mongodbcommunity; fi ",
"turnOnMongo": "brew services start mongodb-community",
"build:webpack": "NODE_ENV=production webpack --config ./SERVERSIDE/webpack/webpack.config.prod.js",
"build": "npm run clean && npm rebuild node-sass && npm run build:webpack && node ./SERVERSIDE/startup",
"build-production": "npm run clean && npm rebuild node-sass && npm run build:webpack",
"start": "node ./SERVERSIDE/startup",
"start-staging": "NODE_ENV=production HOST_MODE=staging node ./SERVERSIDE/startup",
"start-production": "NODE_ENV=production HOST_MODE=production node ./SERVERSIDE/startup",
"checkDeps": "npm run checkMongo && npm run turnOnMongo && npm run checkYarn",
"setup": "git pull origin master && npm run checkDeps && yarn install && npm run build",
"heroku-postbuild": "npm run build-production && ls ./CLIENTSIDE/static",
"lint": "eslint"
},
"dependencies": {
"axios": "^0.19.1",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-stage-0": "^6.24.1",
"body-parser": "~1.19.0",
"classnames": "^2.2.6",
"clipboard": "^2.0.4",
"cookie-parser": "~1.4.4",
"cookie-session": "^1.4.0",
"cors": "^2.8.5",
"css-loader": "^3.4.2",
"detect-browser": "^4.8.0",
"dotenv": "^8.2.0",
"ejs": "^2.7.4",
"express": "^4.17.1",
"express-session": "^1.17.0",
"express-ssl": "^3.1.0",
"express-stormpath": "^4.0.0",
"extend": "^3.0.2",
"fs": "^0.0.1-security",
"gsap": "^3.0.5",
"helmet": "^3.21.2",
"heroku-ssl-redirect": "^0.0.4",
"imports-loader": "^0.8.0",
"jquery": "^3.4.1",
"mobx": "^5.15.2",
"mobx-react": "^6.1.5",
"mongodb-uri": "^0.9.7",
"mongoose": "^5.8.7",
"morgan": "1.9.1",
"node-sass": "^4.13.1",
"node-schedule": "^1.3.2",
"on-build-webpack": "^0.1.0",
"passport": "^0.4.1",
"passport-local": "^1.0.0",
"passport-session": "^1.0.2",
"query-string": "^6.10.1",
"react": "^16.12.0",
"react-addons-transition-group": "^15.6.2",
"react-aria-menubutton": "^6.2.0",
"react-dom": "^16.12.0",
"react-json-tree": "^0.11.2",
"react-responsive": "^8.0.1",
"react-select": "^3.0.8",
"react-share": "^4.0.1",
"react-star-rating": "^1.4.2",
"react-stars": "^2.2.5",
"react-transition-group": "^4.3.0",
"react-transition-group-plus": "^0.5.3",
"request-ip": "^2.1.3",
"rimraf": "^3.0.0",
"roman-numerals": "^0.3.2",
"sass-loader": "^7.3.1",
"serve-favicon": "~2.5.0",
"shortid": "^2.2.15",
"strip-loader": "^0.1.2",
"striptags": "^3.1.1",
"style-loader": "^1.1.3",
"superagent": "^5.2.1",
"svg-text-wrap": "^0.0.1",
"uglify-js": "^3.7.5",
"uglifyjs-webpack-plugin": "^2.2.0",
"underscore": "^1.9.2",
"universal-analytics": "^0.4.20",
"uuid": "^3.4.0",
"uuidv4": "^6.0.1",
"webpack": "^4.41.5",
"webpack-dev-middleware": "^3.7.2",
"webpack-hot-middleware": "^2.25.0"
},
"devDependencies": {
"babel-eslint": "^10.0.3",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.20.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.18.0",
"react-hot-loader": "^4.12.18",
"react-transform-catch-errors": "^1.0.2",
"react-transform-hmr": "^1.0.4",
"redbox-react": "^1.6.0",
"serviceworker-webpack-plugin": "^1.0.1",
"webpack-cli": "^3.3.10"
},
"engines": {
"node": "13.6.0"
}
}
有人知道从哪里开始解决这个问题吗 你也可以分享
package.json
吗?@funnydman我把它添加到了上面的原始问题中。