diff --git a/dev/start.js b/dev/start.js index 1878bcba..e8570719 100644 --- a/dev/start.js +++ b/dev/start.js @@ -59,12 +59,14 @@ function serv() { const message = debounce(stats => { const statistics = stats.toString({ + assets: false, colors: true, - cached: true, - reasons: false, - source: false, + version: false, + hash: false, + timings: false, chunks: false, - children: false + chunkModules: false, + errorDetails: true }); const uri = `http://localhost:${PORT}/`; diff --git a/karma.conf-coverage.js b/karma.conf-coverage.js index f9962e01..d073cb5d 100644 --- a/karma.conf-coverage.js +++ b/karma.conf-coverage.js @@ -23,16 +23,11 @@ const wpConfig = merge(webpackConfig, { loaders: [ { test: /\.js$/, - loader: 'babel-istanbul-loader', + use: 'babel-istanbul-loader', exclude: /(bower_components|node_modules)/ } ] - }, - - debug: false, - cache: false, - watch: false - + } }); module.exports = function(config) { @@ -124,4 +119,3 @@ module.exports = function(config) { }); }; - diff --git a/karma.conf-debug.js b/karma.conf-debug.js index 8d333d42..89c64979 100644 --- a/karma.conf-debug.js +++ b/karma.conf-debug.js @@ -16,11 +16,7 @@ const wpConfig = merge(webpackConfig, { } }, - devtool: 'inline-source-map', - - debug: true, - cache: false, - watch: true + devtool: 'inline-source-map' }); @@ -115,4 +111,3 @@ module.exports = function(config) { }); }; - diff --git a/karma.conf-sauce-labs.js b/karma.conf-sauce-labs.js index 69a36525..c767ced0 100644 --- a/karma.conf-sauce-labs.js +++ b/karma.conf-sauce-labs.js @@ -21,17 +21,13 @@ const wpConfig = merge(webpackConfig, { loaders: [ { test: /\.js$/, - loader: 'babel-istanbul-loader', + use: 'babel-istanbul-loader', exclude: /(bower_components|node_modules)/ } ] }, - devtool: 'inline-source-map', - - debug: false, - cache: false, - watch: false + devtool: 'inline-source-map' }); diff --git a/karma.conf.js b/karma.conf.js index d85a5d71..79b02942 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -16,11 +16,7 @@ const wpConfig = merge(webpackConfig, { } }, - devtool: 'inline-source-map', - - debug: false, - cache: false, - watch: false + devtool: 'inline-source-map' }); @@ -114,4 +110,3 @@ module.exports = function(config) { }); }; - diff --git a/package.json b/package.json index 1b2133f6..e51e374c 100644 --- a/package.json +++ b/package.json @@ -61,21 +61,22 @@ "license": "MIT", "devDependencies": { "animate.css": "^3.5.2", - "autoprefixer": "^6.7.2", - "babel-cli": "^6.22.2", - "babel-core": "^6.22.1", + "autoprefixer": "^6.7.3", + "babel": "^6.23.0", + "babel-cli": "^6.23.0", + "babel-core": "^6.23.1", "babel-eslint": "7.1.1", "babel-istanbul-loader": "0.1.0", - "babel-loader": "^6.2.10", - "babel-plugin-transform-class-properties": "^6.22.0", - "babel-plugin-transform-object-assign": "^6.8.0", - "babel-preset-es2015": "^6.22.0", + "babel-loader": "^6.3.1", + "babel-plugin-transform-object-assign": "^6.22.0", + "babel-preset-latest": "^6.22.0", "babel-preset-stage-0": "^6.5.0", - "babel-register": "^6.22.0", + "babel-register": "^6.23.0", + "babel-runtime": "^6.22.0", "chalk": "^1.1.1", "cheerio": "0.22.0", "chokidar": "1.6.1", - "copyfiles": "^1.0.0", + "copyfiles": "^1.2.0", "cross-env": "^3.1.4", "css-loader": "0.26.1", "dateformat": "2.0.0", @@ -84,8 +85,9 @@ "del": "2.2.2", "eslint": "^3.15.0", "eslint-config-availity": "^2.0.2", + "exports-loader": "^0.6.4", "expose-loader": "^0.7.3", - "extract-text-webpack-plugin": "1.0.1", + "extract-text-webpack-plugin": "^2.1.0", "file-loader": "^0.10.0", "gh-pages": "0.12.0", "globby": "6.1.0", @@ -96,9 +98,9 @@ "isparta-loader": "^2.0.0", "jasmine-core": "2.5.2", "json-loader": "0.5.4", - "karma": "^1.4.1", - "karma-chrome-launcher": "2.0.0", - "karma-coverage": "1.1.1", + "karma": "^1.5.0", + "karma-chrome-launcher": "^2.0.0", + "karma-coverage": "^1.1.1", "karma-fixture": "0.2.6", "karma-jasmine": "^1.1.0", "karma-notify-reporter": "1.0.1", @@ -106,7 +108,7 @@ "karma-sauce-launcher": "1.1.0", "karma-sinon": "1.0.5", "karma-sourcemap-loader": "0.3.7", - "karma-spec-reporter": "0.0.26", + "karma-spec-reporter": "0.0.30", "karma-webpack": "^2.0.2", "karma-webpack-error-reporter": "0.0.3", "less": "^2.7.2", @@ -135,6 +137,7 @@ "ora": "^1.1.0", "phantomjs-prebuilt": "^2.1.14", "postcss-loader": "^1.2.2", + "require-relative": "^0.8.7", "sass-loader": "^6.0.0", "sinon": "^1.17.7", "slugify": "^1.1.0", @@ -142,9 +145,9 @@ "style-loader": "0.13.1", "syntax-highlighting": "github:atelierbram/syntax-highlighting", "url-loader": "0.5.7", - "webpack": "1.13.3", + "webpack": "^2.2.1", "webpack-bundle-analyzer": "^2.2.2", - "webpack-dev-server": "1.16.2", + "webpack-dev-server": "^2.3.0", "webpack-merge": "^2.6.1", "webpack-notifier": "^1.5.0", "yargs": "^6.6.0" @@ -161,14 +164,12 @@ "bootstrap": "^3.3.7", "bootstrap-datepicker": "^1.6.4", "jquery": "^3.0.0", - "lodash.assign": "^4.2.0", "lodash.debounce": "^4.0.8", + "lodash.find": "^4.6.0", + "lodash.findindex": "^4.6.0", "lodash.isempty": "^4.4.0", "lodash.isregexp": "^4.0.1", - "lodash.isstring": "^4.0.1", - "lodash.isundefined": "^3.0.1", "lodash.matches": "^4.6.0", - "lodash.merge": "^4.6.0", "lodash.union": "^4.6.0", "moment": "^2.0.0", "select2": "^3.5.2-browserify", diff --git a/src/core/analytics/config-provider.js b/src/core/analytics/config-provider.js index 52b34282..8b6f8758 100644 --- a/src/core/analytics/config-provider.js +++ b/src/core/analytics/config-provider.js @@ -1,6 +1,5 @@ import angular from 'angular'; import ngModule from '../module'; -import merge from 'lodash.merge'; const CONFIG = { VIRTUAL_PAGE_TRACKING: true, @@ -27,7 +26,7 @@ class AvAnalyticsConfigProvider { } set(options) { - merge(this.options, options); + angular.merge(this.options, options); } $get() { diff --git a/src/core/analytics/exceptions.js b/src/core/analytics/exceptions.js index 6c5374b1..0e20a3fc 100644 --- a/src/core/analytics/exceptions.js +++ b/src/core/analytics/exceptions.js @@ -62,8 +62,12 @@ class AvExceptionAnalyticsProvider { const length = stacktrace.stack.length; for (let i = 0; i < length; i++) { + let iMessage = i.toString(); + while (iMessage.length < 2) { + iMessage = '0' + iMessage; + } message += [ - `[${i.toString().padStart(2, '0')}] `, + `[${iMessage}] `, stacktrace.stack[i].func, ' ', stacktrace.stack[i].url, @@ -167,5 +171,3 @@ ngModule.config( $provide => { ngModule.run( avExceptionAnalytics => avExceptionAnalytics.init()); export default ngModule; - - diff --git a/src/core/api/organizations.js b/src/core/api/organizations.js index 40c261f9..de65111e 100644 --- a/src/core/api/organizations.js +++ b/src/core/api/organizations.js @@ -1,5 +1,4 @@ -import merge from 'lodash.merge'; - +import angular from 'angular'; import ngModule from '../module'; const OrganizationResourceFactory = function(AvApiResource, avUsersResource) { @@ -26,7 +25,7 @@ const OrganizationResourceFactory = function(AvApiResource, avUsersResource) { }; // merge in params with user ID - const queryConfig = merge({}, params, config); + const queryConfig = angular.merge({}, params, config); return this.query(queryConfig); } @@ -48,4 +47,3 @@ const OrganizationResourceFactory = function(AvApiResource, avUsersResource) { ngModule.factory('avOrganizationsResource', OrganizationResourceFactory); export default ngModule; - diff --git a/src/core/api/providers.js b/src/core/api/providers.js index dc41cb8e..556d011a 100644 --- a/src/core/api/providers.js +++ b/src/core/api/providers.js @@ -1,5 +1,4 @@ -import merge from 'lodash.merge'; - +import angular from 'angular'; import ngModule from '../module'; const ProvidersResourceFactory = function(AvApiResource) { @@ -26,7 +25,7 @@ const ProvidersResourceFactory = function(AvApiResource) { }; // merge in params with user ID - const queryConfig = merge({}, params, config); + const queryConfig = angular.merge({}, params, config); return this.query(queryConfig); } @@ -39,4 +38,3 @@ const ProvidersResourceFactory = function(AvApiResource) { ngModule.factory('avProvidersResource', ProvidersResourceFactory); export default ngModule; - diff --git a/src/core/authorizations/index.js b/src/core/authorizations/index.js index 29bb6995..9d18e931 100644 --- a/src/core/authorizations/index.js +++ b/src/core/authorizations/index.js @@ -1,5 +1,6 @@ import angular from 'angular'; import union from 'lodash.union'; +import find from 'lodash.find'; import ngModule from '../module'; import '../api'; @@ -60,7 +61,7 @@ const AvUserAuthorizationsFactory = ($q, $log, avUserPermissionsResource) => { } return this.getPermissions([permissionId]) - .then(permissions => permissions.find(permission => permission.id === permissionId)); + .then(permissions => find(permissions, ['id', permissionId])); } getPermissions(permissionIds) { @@ -86,8 +87,7 @@ const AvUserAuthorizationsFactory = ($q, $log, avUserPermissionsResource) => { getPayers(permissionId, organizationId) { return this.getPermission(permissionId).then(permission => { - - const organization = permission.organizations.find(thisPermission => thisPermission.id === organizationId); + const organization = find(permission.organizations, ['id', organizationId]); if (organization && organization.resources) { return organization.resources; @@ -106,7 +106,7 @@ const AvUserAuthorizationsFactory = ($q, $log, avUserPermissionsResource) => { const result = permissionIds.map(permissionId => { const key = {id: permissionId}; - let permission = permissions.find(thisPermission => thisPermission.id === permissionId); + let permission = find(permissions, ['id', permissionId]); permission = permission ? self.convert(permission) : self.convert(key); return permission; diff --git a/src/core/messages/index.js b/src/core/messages/index.js index aea786d7..31c0e69d 100644 --- a/src/core/messages/index.js +++ b/src/core/messages/index.js @@ -1,7 +1,6 @@ import angular from 'angular'; import $ from 'jquery'; import debounce from 'lodash.debounce'; -import isString from 'lodash.isstring'; import ngModule from '../module'; import './constants'; @@ -145,7 +144,7 @@ class AvMessageProvider { try { - const message = isString(payload) ? payload : JSON.stringify(payload); + const message = angular.isString(payload) ? payload : JSON.stringify(payload); this.postMessage(message, this.domain()); } catch (err) { diff --git a/src/core/validation/validators/npi.js b/src/core/validation/validators/npi.js index 8e91dac1..5d0abdba 100644 --- a/src/core/validation/validators/npi.js +++ b/src/core/validation/validators/npi.js @@ -25,7 +25,7 @@ ngModule.factory('avValNpi', avValUtils => { } const firstDigit = npi.charAt(0); - if (!['1', '2', '3', '4'].includes(firstDigit)) { + if ('1234'.indexOf(firstDigit) < 0) { return false; } diff --git a/src/index.js b/src/index.js index 31f96373..9ec5991d 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,3 @@ -import 'babel-polyfill'; import './core'; import './ui'; diff --git a/src/specs.js b/src/specs.js index 1b6e67cf..29b45dc2 100644 --- a/src/specs.js +++ b/src/specs.js @@ -1,5 +1,4 @@ /* eslint no-var: 0 */ -require('babel-polyfill'); require('bootstrap'); require('availity-uikit'); require('angular'); diff --git a/src/test/index.js b/src/test/index.js index a5740217..4255ddbf 100644 --- a/src/test/index.js +++ b/src/test/index.js @@ -38,32 +38,30 @@ class Tester { directive() { - const self = this; - beforeEach(inject( (_$rootScope_, _$compile_, _$anchorScroll_, _$window_, _$controller_, _$location_, _$q_, _$timeout_, _$httpBackend_, _$http_) => { - self.$scope = _$rootScope_.$new(); - self.sandboxEl = $('
').attr('id', 'sandbox').appendTo($('body')); - self.$compile = _$compile_; - self.$controller = _$controller_; - self.$location = _$location_; - self.$window = _$window_; - self.$anchorScroll = _$anchorScroll_; - self.$q = _$q_; - self.$timeout = _$timeout_; - self.$http = _$http_; - self.$httpBackend = _$httpBackend_; - self.spyBroadast = spyOn(_$rootScope_, '$broadcast').and.callThrough(); - self.spy = jasmine.createSpy('event'); + this.$scope = _$rootScope_.$new(); + this.sandboxEl = $('
').attr('id', 'sandbox').appendTo($('body')); + this.$compile = _$compile_; + this.$controller = _$controller_; + this.$location = _$location_; + this.$window = _$window_; + this.$anchorScroll = _$anchorScroll_; + this.$q = _$q_; + this.$timeout = _$timeout_; + this.$http = _$http_; + this.$httpBackend = _$httpBackend_; + this.spyBroadast = spyOn(_$rootScope_, '$broadcast').and.callThrough(); + this.spy = jasmine.createSpy('event'); })); afterEach( () => { - self.$scope.$destroy(); - self.sandboxEl.remove(); - self.$httpBackend.verifyNoOutstandingExpectation(); - self.$httpBackend.verifyNoOutstandingRequest(); + this.$scope.$destroy(); + this.sandboxEl.remove(); + this.$httpBackend.verifyNoOutstandingExpectation(); + this.$httpBackend.verifyNoOutstandingRequest(); }); } diff --git a/src/ui/datepicker/controller.js b/src/ui/datepicker/controller.js index 06efbc7c..2f642d52 100644 --- a/src/ui/datepicker/controller.js +++ b/src/ui/datepicker/controller.js @@ -79,7 +79,7 @@ class AvDatepickerController { Object.keys(this.av.$attrs).forEach((key) => { const value = self.av.$attrs[key]; const _key = key.replace('data-', ''); - if (this.av.AV_DATEPICKER.OPTIONS.includes(_key)) { + if (this.av.AV_DATEPICKER.OPTIONS.indexOf(_key) >= 0) { self.options[_key] = self.av.$scope.$eval(value); } }); diff --git a/src/ui/dropdown/controller.js b/src/ui/dropdown/controller.js index 0328994e..a13285bc 100644 --- a/src/ui/dropdown/controller.js +++ b/src/ui/dropdown/controller.js @@ -1,4 +1,5 @@ import angular from 'angular'; +import findIndex from 'lodash.findindex'; import matches from 'lodash.matches'; import isEmpty from 'lodash.isempty'; @@ -75,7 +76,7 @@ class AvDropdownController { values.push(e.added); } else { // Removing from collection - const index = values.findIndex(value => matches(e.removed)(value)); + const index = findIndex(values, value => matches(e.removed)(value)); values.splice(index, 1); } @@ -134,7 +135,7 @@ class AvDropdownController { const optionValues = this.valuesFn(self.av.$scope) || []; const optionValuesKeys = this.getOptionValuesKeys(optionValues); - const index = this.collection.findIndex( item => { + const index = findIndex(this.collection, item => { return angular.equals(model, item); }); diff --git a/src/ui/modal/service.js b/src/ui/modal/service.js index 0f4e92de..3b4d0735 100644 --- a/src/ui/modal/service.js +++ b/src/ui/modal/service.js @@ -1,5 +1,4 @@ import angular from 'angular'; -import isUndefined from 'lodash.isundefined'; import ngModule from '../module'; import '../templates'; @@ -89,7 +88,7 @@ const ModalFactory = ($rootScope, $timeout, $compile, $controller, $log, AV_MODA 'remote': this.options.remote }); - if (isUndefined(this.options.show) || this.options.show) { + if (angular.isUndefined(this.options.show) || this.options.show) { this.$element.modal('show'); } diff --git a/src/ui/placeholder/index.js b/src/ui/placeholder/index.js index 3be9b9ad..d1df65cb 100644 --- a/src/ui/placeholder/index.js +++ b/src/ui/placeholder/index.js @@ -1,27 +1,4 @@ +import 'angular-shims-placeholder'; import ngModule from '../module'; ngModule.requires.push('ng.shims.placeholder'); - -ngModule.config(function($provide) { - - $provide.decorator('placeholderDirective', function($delegate, $log) { - - const directive = $delegate[0]; - const originalLink = directive.link; - - const newLink = function(scope, element, attrs) { - - if (originalLink && Object.keys(attrs).indexOf('avMask') > -1) { - $log.info('placeholder shim not running on an element due to avMask on same element'); - } else if (originalLink) { - originalLink.apply(this, arguments); - } - }; - - directive.compile = () => newLink; - - return $delegate; - }); - -}); - diff --git a/src/ui/placeholder/tests/placeholder-spec.js b/src/ui/placeholder/tests/placeholder-spec.js index a488572d..9956580a 100644 --- a/src/ui/placeholder/tests/placeholder-spec.js +++ b/src/ui/placeholder/tests/placeholder-spec.js @@ -1,14 +1,15 @@ -/* global describe, it, jasmine, expect, beforeEach, module, inject */ +/* global describe, it, jasmine, expect, beforeEach, inject */ import $ from 'jquery'; import angular from 'angular'; import Tester from 'tester'; import '../'; +import '../../validation'; describe('placeholder', () => { let $el; - const placeholderSniffer = null; + let placeholderSniffer = null; let $compile; let scope; const tester = new Tester(); @@ -16,19 +17,14 @@ describe('placeholder', () => { const fixtures = { 'default': '', 'model': '', - 'testValue': '', - 'phone': '', - 'datepicker': '', - 'custom': '' + 'testValue': '' }; beforeEach(() => { - - module('ng.shims.placeholder'); - module('availity', avValProvider => { - + angular.mock.module('ng.shims.placeholder'); + angular.mock.module('availity', (avValProvider) => { avValProvider.addRules({ - regular: { + default: { lastName: { size: { min: 2, @@ -46,10 +42,10 @@ describe('placeholder', () => { } }); }); - module('availity.ui'); + angular.mock.module('availity.ui'); }); - tester.directiveSpecHelper(); + tester.directive(); beforeEach(inject(function($injector, _placeholderSniffer_) { $compile = $injector.get('$compile'); @@ -188,44 +184,4 @@ describe('placeholder', () => { }); - describe('with plugins', function() { - - it('should work with phone mask', function() { - - tester.$scope.demo.data = null; - $el = tester.compileDirective(fixtures.phone); - $el.val('9041234567').trigger('change'); - tester.$scope.$digest(); - - expect(tester.$scope.demo.data).toBe('(904) 123-4567'); - }); - - it('should work with avDatepicker', function() { - - tester.$scope.demo.data = null; - $el = tester.compileDirective(fixtures.datepicker); - - $el.val('12122015').trigger('change'); - tester.$scope.$digest(); - - const date = tester.$scope.demo.data; - - expect(date instanceof Date).toBe(true); - expect(date.getFullYear()).toBe(2015); - expect(date.getMonth()).toBe(11); - expect(date.getDate()).toBe(12); - }); - - it('should work with custom mask format', function() { - - tester.$scope.demo.data = null; - $el = tester.compileDirective(fixtures.custom); - - $el.val('1a234').trigger('change'); - tester.$scope.$digest(); - - expect(tester.$scope.demo.data).toBe('1a23_'); - }); - }); - }); diff --git a/src/ui/validation/docs/validation-rules.js b/src/ui/validation/docs/validation-rules.js index 5a3bbd90..0ff0911e 100644 --- a/src/ui/validation/docs/validation-rules.js +++ b/src/ui/validation/docs/validation-rules.js @@ -1,4 +1,4 @@ -import assignIn from 'lodash.assignin'; +import angular from 'angular'; const defaultRules = { ssn: { @@ -93,7 +93,7 @@ const defaultRules = { } }; -const stateRules = assignIn({}, defaultRules, { +const stateRules = angular.merge({}, defaultRules, { 'lastName': null, 'firstName': { 'required': null, diff --git a/src/ui/validation/docs/validation-service.js b/src/ui/validation/docs/validation-service.js index c8679b12..d14588bf 100644 --- a/src/ui/validation/docs/validation-service.js +++ b/src/ui/validation/docs/validation-service.js @@ -1,5 +1,3 @@ -import assign from 'lodash.assign'; - import demo from 'demo'; demo.factory('demoValidationService', AV_VAL => { @@ -27,7 +25,7 @@ demo.factory('demoValidationService', AV_VAL => { ]; // keep a copy of the original state - this.originalState = assign({}, this); + this.originalState = Object.assign({}, this); } @@ -36,7 +34,7 @@ demo.factory('demoValidationService', AV_VAL => { } reset($scope) { - assign(this, this.originalState); + Object.assign(this, this.originalState); $scope.$broadcast(AV_VAL.EVENTS.RESET); } @@ -45,4 +43,3 @@ demo.factory('demoValidationService', AV_VAL => { return new DemoValidationService(); }); - diff --git a/src/ui/validation/tests/form-spec.js b/src/ui/validation/tests/form-spec.js index 539bdfed..71477caf 100644 --- a/src/ui/validation/tests/form-spec.js +++ b/src/ui/validation/tests/form-spec.js @@ -8,8 +8,8 @@ import Tester from 'tester'; describe('avForm', () => { const tester = new Tester(); - let DEBOUNCE; + let DEBOUNCE; beforeEach(() => { angular.mock.module('availity', avValProvider => { @@ -47,10 +47,10 @@ describe('avForm', () => { }); }); - let $el; - tester.directive(); + let $el; + beforeEach(() => { tester.$scope.submit = jasmine.createSpy('submit'); diff --git a/webpack.config.common.js b/webpack.config.common.js index 1307efc6..8f843470 100644 --- a/webpack.config.common.js +++ b/webpack.config.common.js @@ -4,7 +4,7 @@ const webpack = require('webpack'); const path = require('path'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const autoprefixer = require('autoprefixer'); -const NpmImportPlugin = require('less-plugin-npm-import'); +const requireRelative = require('require-relative'); const banner = require('./dev/banner'); @@ -21,44 +21,70 @@ const config = { }, resolve: { - root: path.resolve('./src'), - extensions: ['', '.js'], + modules: [ + path.resolve('./src'), + path.join(__dirname, 'node_modules') + ], + extensions: ['.js'], alias: { // without this $.fn.datepicker will be undefined. Datepicker plugin // tried to load it's own version of jQuery jquery: require.resolve('jquery') } }, - - debug: false, - cache: false, - watch: false, + resolveLoader: { + modules: [ + path.join(__dirname, 'node_modules') + ], + symlinks: true + }, module: { - loaders: [ + rules: [ { test: /\.js$/, - loader: 'babel', + use: 'babel-loader', exclude: /(bower_components|node_modules)/ }, { test: /\.json$/, - loader: 'json' + use: 'json-loader' }, { test: /\.css$/, - loader: ExtractTextPlugin.extract('style', 'css') + use: ExtractTextPlugin.extract({ + fallback: 'style-loader', + use: [ + 'css-loader?limit=32768?name=images/[name].[ext]', + 'postcss-loader' + ], + publicPath: '../' + }) }, { test: /\.less$/, - loader: ExtractTextPlugin.extract( - 'style', - 'css?limit=32768?name=images/[name].[ext]!postcss!less', - { - publicPath: '../' - } - ) + use: ExtractTextPlugin.extract({ + fallback: 'style-loader', + use: [ + 'css-loader?limit=32768?name=images/[name].[ext]', + 'postcss-loader', + 'less-loader' + ], + publicPath: '../' + }) + }, + { + test: /\.scss$/, + use: ExtractTextPlugin.extract({ + fallback: 'style-loader', + use: [ + 'css-loader?limit=32768?name=images/[name].[ext]', + 'postcss-loader', + 'sass-loader' + ], + publicPath: '../' + }) }, { // test should match the following: @@ -67,69 +93,90 @@ const config = { // '../fonts/availity-font.eot' // test: /\.(ttf|woff|eot|svg).*/, - loader: 'file?name=fonts/[name].[ext]' - }, - { - test: /\.scss$/, - loaders: ['style', 'css', 'sass'] + use: 'file-loader?name=fonts/[name].[ext]' }, { - test: /\.(jpe?g|png|gif)$/, - loader: 'url?limit=32768?name=images/[name].[ext]' + test: /\.(jpe?g|png|gif|svg)$/i, + use: [ + 'url-loader?name=images/[name].[ext]&limit=10000' + ] }, { test: /tests.*\.html$/, - loader: 'html' + use: 'html-loader' }, { // Files ending in *.html will be loaded into Angular $templaceCache relative to 'lib' folder. test: /\.html$/, exclude: /tests/, - loader: `ngtemplate?relativeTo=${process.cwd()}/!html` + use: [ + `ngtemplate-loader?relativeTo=${process.cwd()}/`, + 'html-loader' + ] + }, + { + test: requireRelative.resolve('angular', process.cwd()), + use: [ + 'expose-loader?angular', + 'exports-loader?angular' + ] + }, + { + test: requireRelative.resolve('jquery', process.cwd()), + use: [ + 'expose-loader?$', + 'expose-loader?jQuery' + ] + }, + { + test: requireRelative.resolve('moment', process.cwd()), + use: [ + 'expose-loader?moment' + ] } ] }, - postcss() { - return [autoprefixer({browsers: ['last 2 versions', 'ie 9-11']})]; - }, - - lessLoader: { - lessPlugins: [ - new NpmImportPlugin({ - prefix: '~' - }) - ] - }, - plugins: [ - - new webpack.BannerPlugin(banner(), { + new webpack.BannerPlugin({ + banner: banner(), exclude: ['vendor'] }), - new webpack.IgnorePlugin(/^\.\/locale$/, [/moment$/]), new webpack.DefinePlugin({ APP_VERSION: JSON.stringify('Unknown') }), - new ExtractTextPlugin('css/[name].css', { - disable: false, - allChunks: true - }), + new ExtractTextPlugin('css/[name].css'), new webpack.ProvidePlugin({ - 'jQuery': 'jquery', 'window.jQuery': 'jquery', - 'jquery': 'jquery', - 'window.jquery': 'jquery', '$': 'jquery', - 'window.$': 'jquery' - }) - + 'jQuery': 'jquery' + }), + new webpack.LoaderOptionsPlugin( + { + test: /\.(s?c|le)ss$/, + debug: false, + options: { + postcss: [ + autoprefixer( + { + browsers: [ + 'last 5 versions', + 'Firefox ESR', + 'not ie < 9' + ] + } + ) + ], + context: __dirname, + output: { path: '/build' } + } + } + ) ] }; module.exports = config; - diff --git a/webpack.config.development.js b/webpack.config.development.js index 13997a09..843e303b 100644 --- a/webpack.config.development.js +++ b/webpack.config.development.js @@ -30,13 +30,9 @@ const config = merge(webpackCommon, { } }, - debug: true, - cache: true, - watch: true, - stats: { + assets: false, colors: true, - reasons: false, hash: false, version: true, timings: true, @@ -57,4 +53,3 @@ const config = merge(webpackCommon, { }); module.exports = config; - diff --git a/webpack.config.production.js b/webpack.config.production.js index 5f1a69c9..f289b43b 100644 --- a/webpack.config.production.js +++ b/webpack.config.production.js @@ -46,10 +46,6 @@ function getConfig(options) { devtool: 'source-map', - debug: false, - cache: false, - watch: false, - stats: { colors: true, reasons: true, @@ -63,16 +59,13 @@ function getConfig(options) { }, plugins: [ - - new webpack.BannerPlugin(banner()), - - new webpack.optimize.OccurenceOrderPlugin(true), - - new ExtractTextPlugin(optimize ? 'css/[name].min.css' : 'css/[name].css', { - disable: false, - allChunks: true + new webpack.BannerPlugin({ + banner: banner(), + exclude: ['vendor'] }), + new ExtractTextPlugin(optimize ? 'css/[name].min.css' : 'css/[name].css'), + new webpack.NoErrorsPlugin(), new webpack.DefinePlugin(ENV_VAR), @@ -95,7 +88,8 @@ function getConfig(options) { }, compressor: { screw_ie8: true, - warnings: false + warnings: false, + drop_console: true } }) ); @@ -105,5 +99,3 @@ function getConfig(options) { } module.exports = getConfig; - -