首页 > react 关于 webpack 打包

react 关于 webpack 打包

"scripts": {
    "start": "webpack-dev-server --content-base public/",
    "stage": "NODE_ENV=staging webpack -p --config --progress",
    "deploy": "NODE_ENV=production webpack -p --config --progress",
    "debug": "NODE_ENV=debug webpack-dev-server --content-base public/"
  },

正常

npm start

可以跑起来了

可运行

npm run deploy

就报错了

$ npm run deploy

> react-scaffold@1.0.0 deploy E:\zan\www\webpack\react-scaffold
> NODE_ENV=production webpack -p --config --progress

'NODE_ENV' ▒▒▒▒▒ڲ▒▒▒▒ⲿ▒▒▒Ҳ▒▒▒ǿ▒▒▒▒еij▒▒▒
▒▒▒▒▒▒▒▒▒ļ▒▒▒

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\\nodejs\\node.exe" "D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "deploy"
npm ERR! node v4.0.0
npm ERR! npm  v2.14.2
npm ERR! code ELIFECYCLE
npm ERR! react-scaffold@1.0.0 deploy: `NODE_ENV=production webpack -p --config --progress`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-scaffold@1.0.0 deploy script 'NODE_ENV=production webpack -p --config --progress'.
npm ERR! This is most likely a problem with the react-scaffold package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     NODE_ENV=production webpack -p --config --progress
npm ERR! You can get their info via:
npm ERR!     npm owner ls react-scaffold
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     E:\zan\www\webpack\react-scaffold\npm-debug.log

而直接运行 webpack -p 正常

哪里写错了吗 求大神指导一下呀


1 . 你得有webpack.production.js文件

2 . 执行webpack --config webpack.production.js


NODE_ENV=production

是linux设置变量的方法,
windows需要用set

set NODE_ENV=production && webpack -p --config --progress

【热门文章】
【热门文章】