【问题标题】:Get handler entry point in webpack.config.js in serverless在无服务器的 webpack.config.js 中获取处理程序入口点
【发布时间】:2019-08-14 03:06:06
【问题描述】:

在 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 aws-lambda serverless


    【解决方案1】:

    我想要一种仅将 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/,
            },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-17
      • 1970-01-01
      • 2021-11-24
      • 2020-06-02
      • 2021-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多