|
| 1 | +/** |
| 2 | + * angular2-expandable-list |
| 3 | + * |
| 4 | + * Copyright 2017, @andreasonny83, All rights reserved. |
| 5 | + * |
| 6 | + * @author: @andreasonny83 <andreasonny83@gmail.com> |
| 7 | + */ |
| 8 | + |
| 9 | +const helpers = require('./helpers'); |
| 10 | +const webpack = require('webpack'); |
| 11 | + |
| 12 | +/** |
| 13 | + * Webpack Plugins |
| 14 | + */ |
| 15 | +const ProvidePlugin = require('webpack/lib/ProvidePlugin'); |
| 16 | +const DefinePlugin = require('webpack/lib/DefinePlugin'); |
| 17 | +const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin'); |
| 18 | +const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin'); |
| 19 | + |
| 20 | +function ngExternal(ns) { |
| 21 | + const ng2Ns = `@angular/${ns}`; |
| 22 | + return { root: ['ng', ns], commonjs: ng2Ns, commonjs2: ng2Ns, amd: ng2Ns }; |
| 23 | +} |
| 24 | + |
| 25 | +module.exports = { |
| 26 | + devtool: 'source-map', |
| 27 | + |
| 28 | + resolve: { |
| 29 | + extensions: ['.ts', '.js'] |
| 30 | + }, |
| 31 | + |
| 32 | + entry: helpers.root('./index.ts'), |
| 33 | + |
| 34 | + output: { |
| 35 | + path: helpers.root('bundles'), |
| 36 | + publicPath: '/', |
| 37 | + filename: 'angular2-expandable-list.umd.js', |
| 38 | + libraryTarget: 'umd', |
| 39 | + library: 'angular2-expandable-list' |
| 40 | + }, |
| 41 | + |
| 42 | + // require those dependencies but don't bundle them |
| 43 | + externals: { |
| 44 | + '@angular/core': ngExternal('core'), |
| 45 | + '@angular/common': ngExternal('common'), |
| 46 | + '@angular/platform-browser': ngExternal('platform-browser'), |
| 47 | + }, |
| 48 | + |
| 49 | + module: { |
| 50 | + rules: [ |
| 51 | + |
| 52 | + { |
| 53 | + test: /\.ts$/, |
| 54 | + use: [ |
| 55 | + { |
| 56 | + loader: 'awesome-typescript-loader', |
| 57 | + options: { |
| 58 | + declaration: false |
| 59 | + } |
| 60 | + }, |
| 61 | + { |
| 62 | + loader: 'angular2-template-loader' |
| 63 | + } |
| 64 | + ], |
| 65 | + exclude: [/\.e2e\.ts$/] |
| 66 | + }, |
| 67 | + |
| 68 | + { |
| 69 | + test: /\.(css|html)?$/, |
| 70 | + use: [ |
| 71 | + { |
| 72 | + loader: 'raw-loader' |
| 73 | + }, |
| 74 | + ] |
| 75 | + }, |
| 76 | + |
| 77 | + ] |
| 78 | + }, |
| 79 | + |
| 80 | + plugins: [ |
| 81 | + // fix the warning in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js |
| 82 | + new ContextReplacementPlugin( |
| 83 | + /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/, |
| 84 | + helpers.root('src') |
| 85 | + ), |
| 86 | + |
| 87 | + new LoaderOptionsPlugin({ |
| 88 | + options: { |
| 89 | + tslintLoader: { |
| 90 | + emitErrors: false, |
| 91 | + failOnHint: false |
| 92 | + } |
| 93 | + } |
| 94 | + }) |
| 95 | + ] |
| 96 | +}; |
0 commit comments