在 webpack.config 中获取处理程序入口点.js在无服务器中



in webpack.config.js我正在使用'serverless-webpack',它让我能够设置entry: slsw.lib.entries,在构建时自动确定正确的处理程序入口点,但我使用的是inq-webpack-plugin-copy,我只想在一个堆栈/服务中应用这个插件,我该怎么做?

const path = require('path');
const slsw = require('serverless-webpack');
const WebpackPluginCopy = require("inq-webpack-plugin-copy");
module.exports = {
entry: slsw.lib.entries,
target: 'node',
module: {
loaders: [{
test: /.js$/,
loaders: ['babel'],
include: __dirname,
exclude: /....node_modules/,
},
{
test: /.json$/,
loaders: ['json']
}, {
test: /.node$/,
loaders: ['node-loader'],
}]
},
externals: [
(function () {
var IGNORES = [
'electron'
];
return function (context, request, callback) {
if (IGNORES.indexOf(request) >= 0) {
return callback(null, "require('" + request + "')");
}
return callback();
};
})()
],
// I WANT THIS TO BE EXECUTED CONDITIONALLY.
plugins: [
new WebpackPluginCopy([
{
from: "bin/wkhtmltopdf",
to: "wkhtmltopdf",
toType: "file",
copyPermissions: true
}
])
]
};

结构:

-webpack.config.js
-services
-service1
-serverless.yml
-lambdas
-service2

我想要一种方法,将 webpack 插件安装到一个服务中,所以对我来说,我为该堆栈创建了一个单独的webpack.config.js文件。 例如。service1目录。但我不想在该目录中复制整个node_modules目录。并设置node_modules路径

module: {
loaders: [
{
test: /.js$/,
loaders: ['babel'],
//This points to the root directory so we can get nodemodules and other stuff
include: path.resolve(__dirname, '../../../'),
exclude: /node_modules/,
},

最新更新