我有一个在 Jenkins 上成功构建的项目,但是当我尝试使用 AWS Codebuild 构建时,它会出现插件错误。该项目基本上是一个 NodeJS 和 ReactJS 项目。我们不想迁移到 Jenkins,因为我们是无服务器的,安装 jenkins 需要一个 EC2 实例。我们不想维护任何服务器。我为 AWS 代码构建尝试了以下环境:
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 运行期间在 AWS codebuild 中的错误日志
ERROR in
Child html-webpack-plugin for "index.html":
+ 3 hidden modules
此外,我在 Codebuild 中的 npm install 期间收到以下警告,但在 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']
},
};