在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
答案 0 :(得分:0)
我想要一种仅将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/,
},