我正在使用Webpack来响应小型应用程序。
在package.json中运行脚本,但不起作用。
建立开发模式成功。
没有选项的构建生产模式失败。
脚本
//
scripts {
"build-prod": "webpack -p --mode production",
"build-dev": "webpack -d --mode development"
}
错误消息是
npm run build-prod
react-scratch@1.0.0 build-prod / Users / ohmihiroki / Dev / my_portfolio / react-scratch webpack-模式生产
未处理的拒绝错误:“。”不在SourceMap中。 在BasicSourceMapConsumer.SourceMapConsumer_sourceContentFor [作为sourceContentFor] (/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/webpack-sources/node_modules/source-map/lib/source-map-consumer.js:753:13) 在/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/webpack-sources/lib/applySourceMap.js:88:47 在SourceNode_walk上[步行](/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/webpack-sources/node_modules/source-map/lib/source-node.js:230:9) 在SourceNode_walk上[步行](/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/webpack-sources/node_modules/source-map/lib/source-node.js:226:13) 在applySourceMap(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/webpack-sources/lib/applySourceMap.js:58:13) 在SourceMapSource.node(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/webpack-sources/lib/SourceMapSource.js:36:11) 在SourceMapSource.proto.sourceAndMap(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/webpack-sources/lib/SourceAndMapMixin.js:29:18) 在getTaskForFile(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/webpack/lib/SourceMapDevToolPlugin.js:64:30) 在/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/webpack/lib/SourceMapDevToolPlugin.js:200:20 在Array.forEach() 在/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/webpack/lib/SourceMapDevToolPlugin.js:177:12 在SyncHook.eval [调用时](在创建时评估(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/tapable/lib/HookCodeFactory.js:19:10), :7:1) 在SyncHook.lazyCompileHook(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/tapable/lib/Hook.js:154:20) 在/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/webpack/lib/Compilation.js:1385:42 在评估时(在创建时评估(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/tapable/lib/HookCodeFactory.js:33:10), :11:1) 在/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/terser-webpack-plugin/dist/index.js:321:9 在步骤(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/terser-webpack-plugin/dist/TaskRunner.js:87:9) 在/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/terser-webpack-plugin/dist/TaskRunner.js:111:15 在tryCatcher(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/util.js:16:23) 在Promise._settlePromiseFromHandler(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:517:31) 在Promise._settlePromise(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:574:18) 在Promise._settlePromise0(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:619:10) 在Promise._settlePromises(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:699:18) 在Promise._fulfill(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:643:18) 在Promise._resolveCallback(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:437:57) 在Promise._settlePromiseFromHandler(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:529:17) 在Promise._settlePromise(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:574:18) 在Promise._settlePromise0(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:619:10) 在Promise._settlePromises(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:699:18) 在Promise._fulfill(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:643:18) 在Promise._resolveCallback(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:437:57) 在Promise._settlePromiseFromHandler(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:529:17) 在Promise._settlePromise(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:574:18) 在Promise._settlePromise0(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:619:10) 在Promise._settlePromises(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:699:18) 在Promise._fulfill(/Users/ohmihiroki/Dev/my_portfolio/react-scratch/node_modules/bluebird/js/release/promise.js:643:18)
项目目录
├── node_modules
├── README.md
├── dist
│ ├── index.html
│ └── js
│ └── main.min.js
├── jsconfig.json
├── package-lock.json
├── package.json
├── src
│ ├── App.js
│ └──index.js
└── webpack.config.js
webpack.config.js
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
/** @type import('webpack').Configuration */
module.exports = {
devtool: "inline-source-map",
context: path.join(__dirname, "./src"),
entry: { main: "./index.js" },
module: {
rules: [{
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
use: ["babel-loader"]
}]
},
output: {
path: path.join(__dirname, "./dist/js"),
filename: "[name].min.js",
chunkFilename: "[name].min.js",
publicPath: '/'
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
watchContentBase: true,
historyApiFallback: true,
hot: true,
open: true,
port: 3000,
inline: true
},
plugins: debug ? [] : [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
],
resolve: {
extensions: ['.wasm', '.mjs', '.js', '.json', '.jsx'],
alias: {
"@": path.join(__dirname, 'src'),
}
}
};
请给我建议。
谢谢。
答案 0 :(得分:0)
我正在使用这些版本
# kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta3/aio/deploy/recommended.yaml
因此命令将是
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0",