2
我有一個項目在Jenkins上成功構建,但是當我嘗試使用AWS Codebuild構建時,它給出了一個插件錯誤。該項目基本上是一個NodeJS和ReactJS項目。我們不想遷移到Jenkins,因爲我們無服務器,安裝jenkins需要一個EC2實例。我們不想維護任何服務器。我曾嘗試以下環境中的AWS codebuild:當我使用aws/codebuild/ubuntu-base:14.04
codebuild環境構建在詹金斯成功,但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的命令時,纔會執行。否則,只有三條命令是我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
下面是AWS codebuild我的錯誤日誌NPM運行期間
ERROR in
Child html-webpack-plugin for "index.html":
+ 3 hidden modules
另外,我在Codebuild的npm安裝過程中得到以下警告,但我在Jenkins中沒有得到此警告
npm WARN deprecated [email protected]: 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']
},
};
嗨,只是檢查,你希望在哪裏主辦的網站(出來的構建)?看看buildspec,我猜你會嘗試在S3中託管它? – Rikusor
是的,它在S3中託管。 @Riku – deosha
Amazon S3不支持服務器端腳本。你不能在那裏託管NodeJS代碼。 http://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html 這意味着你的版本只應該運行命令,把網站的最終完全靜態版本,並上傳這些文件到S3。意義例如npm run不應該是構建過程的一部分。 – Rikusor