node.js - 在 Jenkins 中构建成功,但 AWS-Codebuild 出现插件错误

标签 node.js reactjs amazon-web-services jenkins aws-codebuild

我有一个在 Jenkins 上成功构建的项目,但是当我尝试使用 AWS Codebuild 进行构建时,它会出现插件错误。该项目基本上是一个 NodeJS 和 ReactJS 项目。我们不想迁移到 Jenkins,因为我们是无服务器的,安装 jenkins 需要一个 EC2 实例。我们不想维护任何服务器。我已经为 AWS codebuild 尝试了以下环境:

aws/codebuild/ubuntu-base:14.04
aws/codebuild/nodejs:6.3.1
aws/codebuild/nodejs:7.0.0
aws/codebuild/nodejs:4.4.7

我的 buildspec.yml 的前四个命令仅在我使用 aws/codebuild/ubuntu-base:14.04 codebuild 环境时执行。否则只有最后三个命令是我的 buildspec.yml 的一部分

下面是我的buildspec.yml

version: 0.1

phases:
  build:
    commands:
      - sudo apt-get update 
      - curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
      - sudo apt-get install -y nodejs
      - sudo apt-get install -y build-essential
      - npm install
      - npm run dev
      - aws s3 cp --recursive dist/ s3://$AWS_BUCKET_NAME/ --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers

下面是我在 npm run 期间在 AWS codebuild 中的错误日志

ERROR in 
Child html-webpack-plugin for "index.html":
+ 3 hidden modules

此外,我在 Codebuild 中的 npm 安装期间收到以下警告,但我在 Jenkins 中没有收到此警告

npm WARN deprecated babel-plugin-react-hot@1.0.4: This plugin is no longer maintained. Please use babel-plugin-react-transform with react-transform-hot-reload instead.

下面是我的 webpack.config.js

var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var FlowStatusWebpackPlugin = require('flow-status-webpack-plugin');

module.exports = {
    entry: [
        './src/app/index.js'
    ],
    output: {
        path: __dirname + '/dist',
        filename: 'index_bundle.js'
    },
    module: {
        loaders: [
            {
                test: /\.json$/,
                loader: 'json'
            },
            {
                test: /\.js$/,
                exclude: /(node_modules|test)/,
                loaders: ["babel-loader"]
            },
            {
                test: /\.(css|scss)$/,
                loaders: ['style', 'css', 'sass-loader']
            },
            {
                test: /\.(png|woff|woff2|eot|ttf|svg)$/,
                loader: 'url-loader',
                options: {
                    limit: 100000,
                    name: 'assets/[hash].[ext]'
                }
            },
            {
                test: /\.styl$/,
                loader: 'style-loader!css-loader!postcss-loader!stylus-loader'
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: __dirname + '/src/app/index.html',
            filename: 'index.html',
            inject: 'body'
        }),
        new webpack.ProvidePlugin({
            $: "jquery",
            jQuery: "jquery"
        }),
        new webpack.DefinePlugin({
            "process.env": {
                'NODE_ENV': JSON.stringify('dev')
            }
        }),
        new FlowStatusWebpackPlugin({
            failOnError: true
        })
    ],
    devtool: 'source-map',
    node: {
        tls: "empty",
        fs: "empty"
    },
    resolve: {
        root: path.resolve(__dirname),
        alias: {
            '~': 'src',
        },
        extensions: ['', '.js', '.jsx']
    },
};

最佳答案

new HtmlWebpackPlugin({
  template: __dirname + '/src/app/index.html',
  filename: 'index.js',
  inject: 'body'
})

filename 选项应该是一个 javascript 文件?即:文件名:index.js

关于node.js - 在 Jenkins 中构建成功,但 AWS-Codebuild 出现插件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44235868/

相关文章:

javascript - 使用 Jest 获取 React 应用程序中的断言总数

java - 同一用户多次发送推送通知的多个 GCM 注册 ID

amazon-web-services - 有关 DynamoDB 中主键和排序键的问题

node.js - squalize 模型的实例是否有更新方法?

javascript - 单击按钮后如何重定向到不同的页面?

javascript - 在 promise 解决之前表达 JS 退出 API

php - 与 AWS DynamoDB 通信时的整秒延迟

node.js - 云函数: TypeError: Cannot read property 'auth' of undefined

javascript - 在 react 组件中迭代json

reactjs - React如何在本地指定动画@keyframes和类