在travis ci上构建webpack

Pav*_*vel 3 node.js travis-ci yarnpkg

我想通过此命令运行webpack build for production:

"prod": "webpack -p --config webpack.production.config.js"
Run Code Online (Sandbox Code Playgroud)

我的.travis.yml档案:

language: node_js
node_js:
  - "6.9.1"

install:
  - npm i -g yarn && yarn

before_script:
  - yarn prod

deploy:
  provider: s3
  local-dir: public
  on:
    branch: cloudfront
Run Code Online (Sandbox Code Playgroud)

但是这个脚本没有加载正确的文件,而且在prod网站上我看到了 ENV=dev

我也试过这些命令:

before_deploy

script

但它没有帮助

webpack.production.config.js:

output: {
  path: path.join(__dirname, 'public'),
  filename: 'index.js',
  publicPath: '/'
},
new webpack.DefinePlugin({
 'process.env': {
   'BASE_URL': JSON.stringify('url'),
   'NODE_ENV': JSON.stringify('production')
 }
})
Run Code Online (Sandbox Code Playgroud)

travis.log:

The command "npm test" exited with 0.
before_deploy
9.54s$ webpack -p --config webpack.production.config.js
Hash: 4aa1139f3ef3381f91ec
Version: webpack 1.13.2
Time: 9133ms
       Asset       Size  Chunks             Chunk Names
    index.js     176 kB       0  [emitted]  main
index.js.map  151 bytes       0  [emitted]  main
   [0] multi main 28 bytes {0} [built]
    + 255 hidden modules
dpl.2
Preparing deploy
dpl.3
Deploying application
uploading "index.html" with {:content_type=>"text/html"}
uploading "index.js.map" with {:content_type=>""}
uploading "index.js" with {:content_type=>"application/javascript"}
# HEAD detached at 8a81ecb
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   public/index.js
#
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (593621bc433e8223b3b5c32751122c23297b202e)
Done. Your build exited with 0.
Run Code Online (Sandbox Code Playgroud)

Pav*_*vel 5

需要将此行添加到.travis.yml:

skip_cleanup: true
Run Code Online (Sandbox Code Playgroud)

这对我很有帮助