2016-10-22 78 views
3

我想運行的WebPack通過此命令建立生產:構建的WebPack

"prod": "webpack -p --config webpack.production.config.js" 

.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 

但是這個劇本不加載正確的文件,並在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') 
} 
}) 

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/[email protected]{0} (593621bc433e8223b3b5c32751122c23297b202e) 
Done. Your build exited with 0. 

回答

4

需要加入這一行.travis.yml:

skip_cleanup: true 

它幫助我的WebPack文件

0

即使你的網站包裝正在生產一捆生產,這並沒有改變en環境在你的服務器上。 ENV在哪裏設置?

+0

,在'新webpack.DefinePlugin({'如果我在本地計算機上運行此命令,所有的工作正常 – Meldum

+0

Webpack只爲你的bundle.js設置「環境」,當你在服務器上運行時,環境可能是服務器需要的任何東西,所以當它爲你的應用程序提供服務時,如果它設置ENV爲dev,那麼這就是你的環境將會顯示。 –

+0

我使用'-p'參數來創建ci,所以在配置生產中我設置了這個變量 – Meldum