2016-10-11 7 views
0

webpack과 함께 babel-polyfill을 사용하려고 할 때 다음과 같은 오류이 계속 발생합니다. babel-loader와 같은 로더없이 어떻게 사용해야합니까? 그것은 환경을 es2015 에뮬레이트합니다 언급했다.webpack에 babel-polyfill 사용하기

ERROR in ./components/App.component.jsx 
Module parse failed: /home/krishna/AndroidStudioProjects/jancan/web/components/App.component.jsx Unexpected token (6:1) 
You may need an appropriate loader to handle this file type. 
SyntaxError: Unexpected token (6:1) 
    at Parser.pp$4.raise (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:2221:15) 
    at Parser.pp.unexpected (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:603:10) 
    at Parser.pp$3.parseExprAtom (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1822:12) 
    at Parser.pp$3.parseExprSubscripts (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1715:21) 
    at Parser.pp$3.parseMaybeUnary (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1692:19) 
    at Parser.pp$3.parseExprOps (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1637:21) 
    at Parser.pp$3.parseMaybeConditional (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1620:21) 
    at Parser.pp$3.parseMaybeAssign (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1597:21) 
    at Parser.pp$3.parseParenAndDistinguishExpression (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1861:32) 
    at Parser.pp$3.parseExprAtom (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1796:19) 
    at Parser.pp$3.parseExprSubscripts (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1715:21) 
    at Parser.pp$3.parseMaybeUnary (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1692:19) 
    at Parser.pp$3.parseExprOps (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1637:21) 
    at Parser.pp$3.parseMaybeConditional (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1620:21) 
    at Parser.pp$3.parseMaybeAssign (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1597:21) 
    at Parser.pp$3.parseFunctionBody (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:2098:24) 
    at Parser.pp$3.parseArrowExpression (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:2087:10) 
    at Parser.pp$3.parseParenArrowList (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1902:17) 
    at Parser.pp$3.parseParenAndDistinguishExpression (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1870:21) 
    at Parser.pp$3.parseExprAtom (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1796:19) 
    at Parser.pp$3.parseExprSubscripts (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1715:21) 
    at Parser.pp$3.parseMaybeUnary (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1692:19) 
    at Parser.pp$3.parseExprOps (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1637:21) 
    at Parser.pp$3.parseMaybeConditional (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1620:21) 
    at Parser.pp$3.parseMaybeAssign (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1597:21) 
    at Parser.pp$1.parseVar (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:1034:28) 
    at Parser.pp$1.parseVarStatement (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:917:10) 
    at Parser.pp$1.parseStatement (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:706:19) 
    at Parser.pp$1.parseTopLevel (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:638:25) 
    at Parser.parse (/home/krishna/AndroidStudioProjects/jancan/web/node_modules/webpack/node_modules/acorn/dist/acorn.js:516:17) 
@ multi main 

편집

내가 바벨 로더를 추가하고 내 웹팩 설정에 babel-polyfill을 사용하는 방법 아직도 내가이이 같은 오류

+0

오류는 매우 간단합니다. 'App.component.jsx' 파일에 구문 오류가 있습니다. 이동하여 확인하십시오. –

+0

App.component.jsx에 오류가 없습니다. –

+0

어떻게 지금 포함 시키시겠습니까? – tobiasandersen

답변

2

을 얻고있다

module.exports = { 
    entry: ['babel-polyfill', './components/App.component.jsx'], 
    output: { 
     path: 'dist/', 
     filename: "bundle.js" 
    }, 
    loaders: [ 
    { 
     test: /\.jsx?$/, 
     exclude: /(node_modules|bower_components)/, 
     loader: 'babel', // 'babel-loader' is also a valid name to reference 
     query: { 
     presets: ['es2015','react'] 
     } 
    } 
    ] 
}; 

내 웹팩 설정. 전체 내용을 보려면 here을 클릭하십시오.

entry: { 
    app: ['babel-polyfill', 'main'] 
    }