Я разрабатываю 2 библиотеки Angular 2:
- CarbonLDP-верстак
- углеродлдп-панель
Проект2 (панель):
Набор экспортируемых компонентов и модулей. Эти компоненты имеют свои собственные шаблоны и файлы scss. Библиотека написана с помощью Typescript, но файлы dist
компилируются, поэтому библиотека поставляется в виде пакета npm
со своими собственными файлами .js
с их файлами .metadata.json
и файлами .d.ts
.
Проект1 (Workbench)
Является основным проектом. Он использует Project2, поэтому он может работать. Этот проект использует Webpack для сборки окончательного приложения. Дело в том, что я не могу заставить webpack работать с Project2 (Panel), потому что основной проект написан на машинописном языке, а панель импортируется только с файлами javascript. Ошибки, которые я получаю от webapack, заключаются в том, что ВСЕ файлы шаблонов из Project2 не могут быть найдены. Смотри ниже:
Вот как окончательный файл app.js объединяет библиотеку Project2. Обратите внимание, как компонент заголовка, полученный из Project2, импортирует файлы шаблонов:
Обратите внимание, как webpack импортирует файлы шаблонов и стилей из main проекта Project1 (написанного с помощью ts):
Вот как я определил правила разрешения расширений в моем файле webpack.config.js
:
entry: {
"polyfills": "./src/polyfills.ts",
"app": "./src/main.ts"
},
resolve: {
extensions: [ ".ts", ".js" ],
alias: {
"app": helpers.root( "src", "app" ),
"jquery": "jquery/src/jquery",
"semantic-ui": helpers.root( "src/semantic/dist" ),
},
modules: [ helpers.root( "node_modules" ) ]
},
module: {
rules: [
{
test: /\.ts$/,
use: [ "awesome-typescript-loader", "angular2-template-loader", "angular-router-loader" ]
},
{
test: /\.html$/,
use: "raw-loader",
exclude: [ helpers.root( "src/index.html" ) ]
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
use: "file-loader?name=assets/[name].[hash].[ext]"
},
{
test: /\.s?css$/,
use: [ "raw-loader", "sass-loader" ]
},
]
},
Возникает вопрос... Как заставить Webpack также компилировать импорт моей библиотеки angular js?