|
| 1 | +import * as webpack from 'webpack'; |
| 2 | +import {ngAppResolve} from './webpack-build-utils'; |
| 3 | + |
| 4 | +const path = require('path'); |
| 5 | +const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin; |
| 6 | +const CopyWebpackPlugin = require('copy-webpack-plugin'); |
| 7 | +const HtmlWebpackPlugin = require('html-webpack-plugin'); |
| 8 | +const DebugWebpackPlugin = require('debug-webpack-plugin'); |
| 9 | + |
| 10 | + |
| 11 | +var components = [ |
| 12 | + 'button', |
| 13 | + 'card', |
| 14 | + 'checkbox', |
| 15 | + 'grid-list', |
| 16 | + 'icon', |
| 17 | + 'input', |
| 18 | + 'list', |
| 19 | + 'progress-bar', |
| 20 | + 'progress-circle', |
| 21 | + 'radio', |
| 22 | + 'sidenav', |
| 23 | + 'slide-toggle', |
| 24 | + 'button-toggle', |
| 25 | + 'tabs', |
| 26 | + 'toolbar' |
| 27 | +]; |
| 28 | +/** Map relative paths to URLs. */ |
| 29 | +var aliasMap = { |
| 30 | + '@angular2-material/core': ngAppResolve('./src/core'), |
| 31 | +}; |
| 32 | + |
| 33 | +components.forEach(function (name) { |
| 34 | + aliasMap[("@angular2-material/" + name)] = ngAppResolve("./src/components/" + name); |
| 35 | + return aliasMap[("@angular2-material/" + name)] = ngAppResolve("./src/components/" + name); |
| 36 | +}); |
| 37 | + |
| 38 | +export const webpackMaterialConfig = { |
| 39 | + devtool: 'inline-source-map', |
| 40 | + resolve: { |
| 41 | + extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js', '.css', '.scss'], |
| 42 | + //SAVE: TODO# Don't use relative bp |
| 43 | + root: ngAppResolve('./'), |
| 44 | + // modulesDirectory: [ |
| 45 | + // ngAppResolve('./src/demo-app/'), |
| 46 | + // ngAppResolve('./src/core'), |
| 47 | + // ngAppResolve('./src/components'), |
| 48 | + // 'src/components/', |
| 49 | + // 'src/core/' |
| 50 | + // ] |
| 51 | + alias: aliasMap |
| 52 | + }, |
| 53 | + debug: true, |
| 54 | + context: path.resolve(__dirname, './'), |
| 55 | + //SAVE entry: { |
| 56 | + // main: [ngAppResolve('./src/main.ts')], |
| 57 | + // vendor: ngAppResolve('./src/vendor.ts'), |
| 58 | + // polyfills: ngAppResolve('./src/polyfills.ts') |
| 59 | + // }, |
| 60 | + entry: { |
| 61 | + main: [ngAppResolve('./src/demo-app/main.ts')], |
| 62 | + // core: ngAppResolve('./src/core/core.ts'), |
| 63 | + // main: ngAppResolve('./src/e2e-app/main.ts') |
| 64 | + }, |
| 65 | + output: { |
| 66 | + path: './dist', |
| 67 | + filename: '[name].bundle.js' |
| 68 | + }, |
| 69 | + module: { |
| 70 | + preLoaders: [ |
| 71 | + { |
| 72 | + test: /\.js$/, |
| 73 | + loader: 'source-map-loader', |
| 74 | + exclude: [ |
| 75 | + ngAppResolve('node_modules/rxjs'), |
| 76 | + ngAppResolve('node_modules/@angular'), |
| 77 | + ] |
| 78 | + } |
| 79 | + ], |
| 80 | + ts: { |
| 81 | + configFileName: ngAppResolve('./src/demo-app/tsconfig.json') |
| 82 | + }, |
| 83 | + loaders: [ |
| 84 | + { |
| 85 | + test: /\.ts$/, |
| 86 | + loaders: [ |
| 87 | + 'ts-loader', 'angular2-template-loader' |
| 88 | + ], |
| 89 | + exclude: [/\.(spec|e2e)\.ts$/] |
| 90 | + }, |
| 91 | + { test: /\.json$/, loader: 'json-loader'}, |
| 92 | + { test: /\.css$/, loaders: ['raw-loader', 'postcss-loader'] }, |
| 93 | + { test: /\.styl$/, loaders: ['raw-loader', 'postcss-loader', 'stylus-loader'] }, |
| 94 | + { test: /\.less$/, loaders: ['raw-loader', 'postcss-loader', 'less-loader'] }, |
| 95 | + { test: /\.s?css$/, loaders: ['raw-loader', 'postcss-loader', 'sass-loader'] }, |
| 96 | + { test: /\.(jpg|png)$/, loader: 'url-loader?limit=128000'}, |
| 97 | + { test: /\.html$/, loader: 'raw-loader' } |
| 98 | + ] |
| 99 | + }, |
| 100 | + plugins: [ |
| 101 | + // new webpack.NormalModuleReplacementPlugin(/@angular2-material\/core/, require.resolve(ngAppResolve('./src/core/core.ts'))), |
| 102 | + // new webpack.NormalModuleReplacementPlugin(/@angular2-material\//, ngAppResolve('./src/components')), |
| 103 | + new DebugWebpackPlugin({ |
| 104 | + // Defaults to ['webpack:*'] which can be VERY noisy, so try to be specific |
| 105 | + // scope: [ |
| 106 | + // 'webpack:compiler:*', // include compiler logs |
| 107 | + // 'webpack:plugin:ExamplePlugin' // include a specific plugin's logs |
| 108 | + // ], |
| 109 | + |
| 110 | + // // Inspect the arguments passed to an event |
| 111 | + // // These are triggered on emits |
| 112 | + // listeners: { |
| 113 | + // 'webpack:compiler:run': function(compiler) { |
| 114 | + // // Read some data out of the compiler |
| 115 | + // } |
| 116 | + // }, |
| 117 | + // Defaults to the compiler's setting |
| 118 | + debug: true |
| 119 | + }), |
| 120 | + new ForkCheckerPlugin(), |
| 121 | + new HtmlWebpackPlugin({ |
| 122 | + template: ngAppResolve('./src/demo-app/index.html'), |
| 123 | + }), |
| 124 | + ], |
| 125 | + node: { |
| 126 | + global: 'window', |
| 127 | + crypto: 'empty', |
| 128 | + module: false, |
| 129 | + clearImmediate: false, |
| 130 | + setImmediate: false |
| 131 | + } |
| 132 | +}; |
0 commit comments