MOBILE-2327 ionic: Use aliases on import paths

main
Pau Ferrer Ocaña 2018-02-23 13:02:56 +01:00
parent 7790596edf
commit 0c4f834c0a
5 changed files with 91 additions and 54 deletions

View File

@ -6,6 +6,9 @@
"name": "Moodle Pty Ltd.", "name": "Moodle Pty Ltd.",
"email": "mobile@moodle.com" "email": "mobile@moodle.com"
}, },
"config": {
"ionic_webpack": "./webpack.config.js"
},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/moodlehq/moodlemobile2.git" "url": "https://github.com/moodlehq/moodlemobile2.git"
@ -77,7 +80,8 @@
"gulp-rename": "^1.2.2", "gulp-rename": "^1.2.2",
"gulp-slash": "^1.1.3", "gulp-slash": "^1.1.3",
"through": "^2.3.8", "through": "^2.3.8",
"typescript": "2.4.2" "typescript": "2.4.2",
"webpack-merge": "^4.1.2"
}, },
"browser": { "browser": {
"electron": false "electron": false

View File

@ -14,14 +14,13 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AddonMessagesProvider } from './messages'; import { AddonMessagesProvider } from './messages';
import { CoreMainMenuDelegate, CoreMainMenuHandler, CoreMainMenuHandlerToDisplay } from import { CoreMainMenuDelegate, CoreMainMenuHandler, CoreMainMenuHandlerToDisplay } from '@core/mainmenu/providers/delegate';
'../../../core/mainmenu/providers/delegate'; import { CoreCronHandler } from '@providers/cron';
import { CoreCronHandler } from '../../../providers/cron'; import { CoreSitesProvider } from '@providers/sites';
import { CoreSitesProvider } from '../../../providers/sites'; import { CoreEventsProvider } from '@providers/events';
import { CoreEventsProvider } from '../../../providers/events'; import { CoreAppProvider } from '@providers/app';
import { CoreAppProvider } from '../../../providers/app'; import { CoreTextUtilsProvider } from '@providers/utils/text';
import { CoreTextUtilsProvider } from '../../../providers/utils/text'; import { CoreLocalNotificationsProvider } from '@providers/local-notifications';
import { CoreLocalNotificationsProvider } from '../../../providers/local-notifications';
/** /**
* Handler to inject an option into main menu. * Handler to inject an option into main menu.

View File

@ -23,54 +23,54 @@ import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { MoodleMobileApp } from './app.component'; import { MoodleMobileApp } from './app.component';
import { CoreInterceptor } from '../classes/interceptor'; import { CoreInterceptor } from '@classes/interceptor';
import { CoreLoggerProvider } from '../providers/logger'; import { CoreLoggerProvider } from '@providers/logger';
import { CoreDbProvider } from '../providers/db'; import { CoreDbProvider } from '@providers/db';
import { CoreAppProvider } from '../providers/app'; import { CoreAppProvider } from '@providers/app';
import { CoreConfigProvider } from '../providers/config'; import { CoreConfigProvider } from '@providers/config';
import { CoreLangProvider } from '../providers/lang'; import { CoreLangProvider } from '@providers/lang';
import { CoreTextUtilsProvider } from '../providers/utils/text'; import { CoreTextUtilsProvider } from '@providers/utils/text';
import { CoreDomUtilsProvider } from '../providers/utils/dom'; import { CoreDomUtilsProvider } from '@providers/utils/dom';
import { CoreTimeUtilsProvider } from '../providers/utils/time'; import { CoreTimeUtilsProvider } from '@providers/utils/time';
import { CoreUrlUtilsProvider } from '../providers/utils/url'; import { CoreUrlUtilsProvider } from '@providers/utils/url';
import { CoreUtilsProvider } from '../providers/utils/utils'; import { CoreUtilsProvider } from '@providers/utils/utils';
import { CoreMimetypeUtilsProvider } from '../providers/utils/mimetype'; import { CoreMimetypeUtilsProvider } from '@providers/utils/mimetype';
import { CoreInitDelegate } from '../providers/init'; import { CoreInitDelegate } from '@providers/init';
import { CoreFileProvider } from '../providers/file'; import { CoreFileProvider } from '@providers/file';
import { CoreWSProvider } from '../providers/ws'; import { CoreWSProvider } from '@providers/ws';
import { CoreEventsProvider } from '../providers/events'; import { CoreEventsProvider } from '@providers/events';
import { CoreSitesFactoryProvider } from '../providers/sites-factory'; import { CoreSitesFactoryProvider } from '@providers/sites-factory';
import { CoreSitesProvider } from '../providers/sites'; import { CoreSitesProvider } from '@providers/sites';
import { CoreLocalNotificationsProvider } from '../providers/local-notifications'; import { CoreLocalNotificationsProvider } from '@providers/local-notifications';
import { CoreGroupsProvider } from '../providers/groups'; import { CoreGroupsProvider } from '@providers/groups';
import { CoreCronDelegate } from '../providers/cron'; import { CoreCronDelegate } from '@providers/cron';
import { CoreFileSessionProvider } from '../providers/file-session'; import { CoreFileSessionProvider } from '@providers/file-session';
import { CoreFilepoolProvider } from '../providers/filepool'; import { CoreFilepoolProvider } from '@providers/filepool';
import { CoreUpdateManagerProvider } from '../providers/update-manager'; import { CoreUpdateManagerProvider } from '@providers/update-manager';
import { CorePluginFileDelegate } from '../providers/plugin-file-delegate'; import { CorePluginFileDelegate } from '@providers/plugin-file-delegate';
import { CoreSyncProvider } from '../providers/sync'; import { CoreSyncProvider } from '@providers/sync';
// Core modules. // Core modules.
import { CoreComponentsModule } from '../components/components.module'; import { CoreComponentsModule } from '@components/components.module';
import { CoreEmulatorModule } from '../core/emulator/emulator.module'; import { CoreEmulatorModule } from '@core/emulator/emulator.module';
import { CoreLoginModule } from '../core/login/login.module'; import { CoreLoginModule } from '@core/login/login.module';
import { CoreMainMenuModule } from '../core/mainmenu/mainmenu.module'; import { CoreMainMenuModule } from '@core/mainmenu/mainmenu.module';
import { CoreCoursesModule } from '../core/courses/courses.module'; import { CoreCoursesModule } from '@core/courses/courses.module';
import { CoreFileUploaderModule } from '../core/fileuploader/fileuploader.module'; import { CoreFileUploaderModule } from '@core/fileuploader/fileuploader.module';
import { CoreSharedFilesModule } from '../core/sharedfiles/sharedfiles.module'; import { CoreSharedFilesModule } from '@core/sharedfiles/sharedfiles.module';
import { CoreCourseModule } from '../core/course/course.module'; import { CoreCourseModule } from '@core/course/course.module';
import { CoreSiteHomeModule } from '../core/sitehome/sitehome.module'; import { CoreSiteHomeModule } from '@core/sitehome/sitehome.module';
import { CoreContentLinksModule } from '../core/contentlinks/contentlinks.module'; import { CoreContentLinksModule } from '@core/contentlinks/contentlinks.module';
import { CoreUserModule } from '../core/user/user.module'; import { CoreUserModule } from '@core/user/user.module';
import { CoreGradesModule } from '../core/grades/grades.module'; import { CoreGradesModule } from '@core/grades/grades.module';
// Addon modules. // Addon modules.
import { AddonCalendarModule } from '../addon/calendar/calendar.module'; import { AddonCalendarModule } from '@addon/calendar/calendar.module';
import { AddonUserProfileFieldModule } from '../addon/userprofilefield/userprofilefield.module'; import { AddonUserProfileFieldModule } from '@addon/userprofilefield/userprofilefield.module';
import { AddonFilesModule } from '../addon/files/files.module'; import { AddonFilesModule } from '@addon/files/files.module';
import { AddonModBookModule } from '../addon/mod/book/book.module'; import { AddonModBookModule } from '@addon/mod/book/book.module';
import { AddonModLabelModule } from '../addon/mod/label/label.module'; import { AddonModLabelModule } from '@addon/mod/label/label.module';
import { AddonMessagesModule } from '../addon/messages/messages.module'; import { AddonMessagesModule } from '@addon/messages/messages.module';
// For translate loader. AoT requires an exported function for factories. // For translate loader. AoT requires an exported function for factories.
export function createTranslateLoader(http: HttpClient): TranslateHttpLoader { export function createTranslateLoader(http: HttpClient): TranslateHttpLoader {

View File

@ -11,7 +11,18 @@
"module": "es2015", "module": "es2015",
"moduleResolution": "node", "moduleResolution": "node",
"sourceMap": true, "sourceMap": true,
"target": "es5" "target": "es5",
"baseUrl": "./src",
"paths": {
"@addon/*": ["addon/*"],
"@classes/*": ["classes/*"],
"@core/*": ["core/*"],
"@providers/*": ["providers/*"],
"@utils": ["providers/utils/*"],
"@components": ["components/*"],
"@directives": ["directives/directives.module"],
"@pipes": ["pipes/pipes.module"]
}
}, },
"include": [ "include": [
"src/**/*.ts" "src/**/*.ts"

23
webpack.config.js 100644
View File

@ -0,0 +1,23 @@
const { resolve } = require('path');
const webpackMerge = require('webpack-merge');
const { dev, prod } = require('@ionic/app-scripts/config/webpack.config');
const customConfig = {
resolve: {
alias: {
'@addon': resolve('./src/addon'),
'@classes': resolve('./src/classes'),
'@core': resolve('./src/core'),
'@providers': resolve('./src/providers'),
'@utils': resolve('./src/providers/utils'),
'@components': resolve('./src/components'),
'@directives': resolve('./src/directives/directives.module'),
'@pipes': resolve('./src/pipes/pipes.module')
}
}
};
module.exports = {
dev: webpackMerge(dev, customConfig),
prod: webpackMerge(prod, customConfig),
}