Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack打包问题。 #27

Closed
WebPuY opened this issue Apr 19, 2018 · 4 comments
Closed

webpack打包问题。 #27

WebPuY opened this issue Apr 19, 2018 · 4 comments

Comments

@WebPuY
Copy link
Contributor

WebPuY commented Apr 19, 2018

修改了webpack配置,增加了一个打包配置:、
"build": "cross-env NODE_ENV=production webpack --config webpack.prod.js"

然后执行 npm run build。报错如下

ERROR in ./app/index.js
Module build failed: ReferenceError: [BABEL] D:\yp\React-Blog-Demo\app\index.js: Unknown option: D:\yp\React-Blog-Demo.babelrc.env.production.preset. Check out http://babeljs.io/docs/usage/options/ for more information about options.

# A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:

Invalid:
{ presets: [{option: value}] }
Valid:
{ presets: [['presetName', {option: value}]] }

For more detailed information on preset configuration, please see http://babeljs.io/docs/plugins/#pluginpresets-options.
at Logger.error (D:\yp\React-Blog-Demo\node_modules\babel-core\lib\transformation\file\logger.js:41:11)
at OptionManager.mergeOptions (D:\yp\React-Blog-Demo\node_modules\babel-core\lib\transformation\file\options\option-manager.js:226:20)
at OptionManager.init (D:\yp\React-Blog-Demo\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
at File.initOptions (D:\yp\React-Blog-Demo\node_modules\babel-core\lib\transformation\file\index.js:212:65)
at new File (D:\yp\React-Blog-Demo\node_modules\babel-core\lib\transformation\file\index.js:135:24)
at Pipeline.transform (D:\yp\React-Blog-Demo\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
at transpile (D:\yp\React-Blog-Demo\node_modules\babel-loader\lib\index.js:50:20)
at Object.module.exports (D:\yp\React-Blog-Demo\node_modules\babel-loader\lib\index.js:173:20)
@ multi babel-polyfill ./app/index.js

@WebPuY
Copy link
Contributor Author

WebPuY commented Apr 23, 2018

bablerc里面的env配置,导致生产打包失败。

@WebPuY
Copy link
Contributor Author

WebPuY commented Apr 23, 2018

babelrc的"presets": ["es2015","react","stage-0", "env"],删掉‘env’就可以了。
还要把下面的 preset配置项改成presets

@WebPuY WebPuY closed this as completed Apr 27, 2018
@WebPuY
Copy link
Contributor Author

WebPuY commented May 3, 2018

作者你好,我补充了生产环境打包构建的代码,没几行,已经在本地跑过,想merge到你的项目里面,可以吗?

@Nealyang
Copy link
Owner

Nealyang commented May 4, 2018

好啊~你提一下pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants