2017-02-10 6 views
0

webpack을 사용하여 동적 요구 사항을 해결할 수 없습니다. 오류동적 인 webpack에서 작동하지 않음이 작동하지 않습니다.

WARNING in ./ace/config.js 
112:21-40 Critical dependency: the request of a dependency is an expression 

WARNING in ./ace/config.js 
142:39-46 Critical dependency: require function is used in a way in which 
dependencies cannot be statically extracted   

WARNING in ./ace/config.js 
124:12-131:14 Critical dependency: the request of a dependency is an 
expression 

얻기 정적 필요한 사용 5 개 파일, 동적 요구 만 1 개의 파일이 있습니다.

내 웹팩 config 파일 우리는 그 역동적를 해결하기 위해 필요한이

var webpack = require('webpack'); 

module.exports = { 
context: __dirname + '/app', 
entry: { 
    services: ["./init.js"] 
}, 
output: { 
    path: __dirname + '/public/javascript', 
    filename: "[name].bundle.js?v=[hash]" 
}, 
module: { 
    loaders: [ 
     { test: /\.json$/, loader: 'json-loader' }, 
     { 
      loader: 'babel-loader', 
      query: { 
       presets: ['es2015', 'stage-0'] 
      } 
     }, 
     { test: /\.css$/, loader: "css-loader" } 
    ] 
}, 
node: { 
    console: true, 
    fs: 'empty', 
    net: 'empty', 
    tls: 'empty' 
}, 
target: 'node' 
}; 
+0

는 에이스 - 빌드에서 미리 컴파일 된 버전을 사용하려고 –

답변

1

같은 것은 그냥 웹팩 그 해결 할 수있는 곳에서 디렉토리를 언급 할 필요가 웹팩 기능 [https://webpack.github.io/docs/context.html][1]

를 사용하여 필요 당신은 또한 동일을 위해 webpack의 ContextReplacementPlugin을 탐색 할 수 있습니다. 모듈 이름은 동적

this => require([module]) 
    to => require(['./directory/' + module + '.js'])