我剛接觸Webpack世界,並且一直在使用TypeScript 1.x。從歷史上看,我的大部分TypeScript工作都在一個模塊中完成(單獨的文件),使用TSD進行類型化,並使用Gulp任務進行編譯。包含用於類型的模塊,但不包括最終的webpack包?
我正在開發一個新項目,並試圖設置一個Webpack + TypeScript 2(和導入/ @types進行類型化)的過程。我找到了一些成功,但我想從我的webpack軟件包中排除某些庫。
我有一個看起來像這樣的目錄結構:
components/
customComponentA/
customComponentB/
node_modules/
@types/
angular/
main.ts
tsconfig.json
webpack.config.js
如果我包括我的自定義組件import * as angular from "angular";
,我看到一堆Can't resolve 'angular'
問題(這是有道理的)。一旦我真的將angular
添加到我的node_modules
,Webpack很高興,但是隨後所有的Angular都包含在我的最終包中。
我想讓我的打字很開心沒有包括Angular在我的最後一捆。這可能嗎?
你可能會有所幫助:https://開頭webpack.github.io/docs/library-and-externals.html –