ES5:'use strict' 内的依赖项无法被 Heroku 缩小
ES5: 'use strict' within dependency fails to be minified by Heroku
我正在尝试在 Heroku 上部署,但出现以下错误:
remote: Failed to minify the code from this file:
remote: ./node_modules/webhoseio/webhoseio.js:13
检查此依赖项后,我发现它使用了 ES5 'use strict';
声明。我怎样才能让 Heroku 编译这个依赖项?
编辑:Package.json 文件
{
"name": "stocks-app",
"version": "1.0.0",
"description": "Mern Demo",
"main": "server.js",
"scripts": {
"start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
"start:prod": "babel-node server.js",
"start:dev": "concurrently \"nodemon --ignore 'client/*'\" \"npm run client\"",
"client": "cd client && npm run start",
"install": "cd client && yarn install",
"build": "cd client && npm run build",
"heroku-postbuild": "npm run build"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"concurrently": "^4.1.0",
"nodemon": "^1.18.9"
},
"dependencies": {
"alphavantage": "^1.2.0",
"axios": "^0.18.0",
"brain.js": "^1.6.0",
"cors": "^2.8.5",
"dotenv": "^6.2.0",
"express": "^4.16.3",
"if-env": "^1.0.4",
"mdbreact": "^4.8.5-patch.1",
"mongoose": "^5.4.0",
"newsapi": "^2.4.0",
"request": "^2.88.0",
"webhoseio": "^1.0.2"
}
}
我通过在我的 Webpack 配置中关闭缩小来解决这个问题。我没有使用 CRA 预配置的 Webpack ES-Lint 加载器,而是安装了 HTML-Loader 并将 loader
设置为它。接下来,我将最小化设置为 false
。方法如下:
module: {
rules: [
{
use: [
{
options: {
formatter: eslintFormatter,
eslintPath: require.resolve('eslint'),
minimize: false,
},
loader: require.resolve('html-loader'),
},
],}}
我正在尝试在 Heroku 上部署,但出现以下错误:
remote: Failed to minify the code from this file:
remote: ./node_modules/webhoseio/webhoseio.js:13
检查此依赖项后,我发现它使用了 ES5 'use strict';
声明。我怎样才能让 Heroku 编译这个依赖项?
编辑:Package.json 文件
{
"name": "stocks-app",
"version": "1.0.0",
"description": "Mern Demo",
"main": "server.js",
"scripts": {
"start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
"start:prod": "babel-node server.js",
"start:dev": "concurrently \"nodemon --ignore 'client/*'\" \"npm run client\"",
"client": "cd client && npm run start",
"install": "cd client && yarn install",
"build": "cd client && npm run build",
"heroku-postbuild": "npm run build"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"concurrently": "^4.1.0",
"nodemon": "^1.18.9"
},
"dependencies": {
"alphavantage": "^1.2.0",
"axios": "^0.18.0",
"brain.js": "^1.6.0",
"cors": "^2.8.5",
"dotenv": "^6.2.0",
"express": "^4.16.3",
"if-env": "^1.0.4",
"mdbreact": "^4.8.5-patch.1",
"mongoose": "^5.4.0",
"newsapi": "^2.4.0",
"request": "^2.88.0",
"webhoseio": "^1.0.2"
}
}
我通过在我的 Webpack 配置中关闭缩小来解决这个问题。我没有使用 CRA 预配置的 Webpack ES-Lint 加载器,而是安装了 HTML-Loader 并将 loader
设置为它。接下来,我将最小化设置为 false
。方法如下:
module: {
rules: [
{
use: [
{
options: {
formatter: eslintFormatter,
eslintPath: require.resolve('eslint'),
minimize: false,
},
loader: require.resolve('html-loader'),
},
],}}