我正在使用无服务器和无服务器webpack。 webpack
配置非常简单:
const path = require('path');
const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: {
lambda: './lambda.js',
},
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, '.webpack'),
filename: '[name].js',
},
target: 'node',
externals: [nodeExternals()],
module: {
rules: [{
test: /\.js$/,
loader: 'babel-loader',
include: __dirname,
exclude: /node_modules/,
}, {
test: /\.json$/,
loader: 'json-loader',
}],
},
stats: "verbose",
};
serverless.yml:
plugins:
- serverless-webpack
- serverless-secrets-plugin
- serverless-plugin-split-stacks
- serverless-offline
custom:
webpack:
webpackConfig: ./webpack.config.js
stage: ${opt:stage, self:provider.stage}
provider:
name: aws
runtime: nodejs8.10
functions:
lambdaFn:
handler: lambda.fn
events:
- http: GET /foo
使用webpack版本8.4进行部署时,控制台输出绝对清晰(即使启用verbose
),并且节点进程占用0%CPU:
node ./node_modules/.bin/serverless offline -p 3001 -s local
Serverless: Bundling with Webpack...
将webpack降级到3.12(最新3. *版本)时,构建成功运行。
至少,我该怎么调试呢?不幸的是,我没有在输出中看到任何错误或提示。