2016-07-29 1 views
1

내 웹팩 설정이index.html을이 vendor.js을 포함하고는 동일한 DIST 폴더에 어디에 "/"

config.output = isTest ? {} : { 
path: __dirname + '/dist', 
publicPath: baseUrl, 
filename: isProd ? '[name].[hash].js' : '[name].bundle.js', 
chunkFilename: isProd ? '[name].[hash].js' : '[name].bundle.js' 
}; 

if (!isTest) { 

config.plugins.unshift(
    new HtmlWebpackPlugin({ 
    template: './app/index.ejs', 
    inject: 'body', 
    baseUrl: '/' 
    }), 
    new ExtractTextPlugin('[name].[hash].css', {disable: !isProd}) 
); 

config.plugins.push(
    new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js') 
); 
} 

를 다음과 같습니다과 app.bundle.js하지만 난 실행할 때 웹팩 셋 모두 동일한 폴더에 있지만 내가 실행할 때/그러므로

<script type="text/javascript" src="/vendors.js"></script><script type="text/javascript" src="/app.bundle.js"></script></body> 

A의 vendor.js /app.bundle.js과 함께 DIST 폴더 index.html 파일을 생성

webpack-dev-server --history-api-fallback --inline --progress --host 0.0.0.0 

제대로 페이지를 렌더링하고 다음과 같이 JQuery와 모듈을 찾을 수 없다는 오류가 발생하지 않습니다

Uncaught ReferenceError: jQuery is not defined(anonymous function) @ transition.js:59__webpack_require__ @ bootstrap 26cc2c2…:50(anonymous function) @ no-op.js?59ab:1__webpack_require__ @ bootstrap 26cc2c2…:50(anonymous function) @ no-op.js:2__webpack_require__ @ bootstrap 26cc2c2…:50(anonymous function) @ loader.js:1__webpack_require__ @ bootstrap 26cc2c2…:50(anonymous function) @ bootstrap 26cc2c2…:96__webpack_require__ @ bootstrap 26cc2c2…:50(anonymous function) @ bootstrap 26cc2c2…:96(anonymous function) @ bootstrap 26cc2c2…:96 angular.js:68 

답변

0

좋아, 내가이 문제를 그럭저럭 한의 웹팩에서 단지 base을가

했다

나는 index.html을이 vendor.js와 app.bundle.js와 웹팩에 의해 생성 될 때, 그것은 index.html을 내부에 스크립트 경로에 base을을 추가 것을 알게

var baseUrl = '/abc/' 
inside index.html, it will be <script type="text/javascript" src="/abc/vendors.js"></script><script type="text/javascript" src="/abc/app.bundle.js"></script></body> </html> 
관련 문제