我使用的WebPack 1,試圖導入外部js文件,寫在AMD模塊的模式,從一個叫Qlik產品,它不可視化。使用Qlik用的WebPack 1
該項目採用角fullstack自耕農發生器,所以的WebPack配置文件是:https://github.com/angular-fullstack/generator-angular-fullstack/blob/master/templates/app/webpack.make.js
試圖得到這樣一個的WebPack環境中工作: https://gist.github.com/mindspank/905294636006b3b530a0#file-index-js-L19
我想文件導入和使用:https://sense-demo.qlik.com/resources/js/qlik.js
我試過像scriptjs這樣的東西來加載它,但webpack無法解決它。
$script('https://sense-demo.qlik.com/resources/assets/external/requirejs/require.js',() => {
require.config = {
baseUrl: 'https://sense-demo.qlik.com/resources'
}
require(['js/qlik'], qlik => {
let app = qlik.openApp(...);
}
});
// throws Module not found: Error: Cannot resolve module 'js/qlik'
我也嘗試在本地將它添加到項目,並在的WebPack引用它:
config.externals = {
'qlik' : 'commonjs2 ./client/assets/js/qlik'
}
usage:
require(['qlik'], qlik => {
console.log(qlik);
});
// throws Uncaught ReferenceError: require is not defined
或
config.resolve = {
root: [
path.join(__dirname, ('/client/assets/js'))
]
};
// throws tons of errors similar to:
ERROR in ./client/assets/js/qlik.js
Module not found: Error: Cannot resolve module 'cm.matchbrackets' in \client\assets\js
我的問題是,我不知道該怎麼通過webpack使用這個外部腳本。在scriptjs內運行時,它無法解析'js/qlik'
,保存qlik腳本並在本地添加它們並不會更好。
任何幫助將大大apprciated!