Skip to content

Commit d166b65

Browse files
committed
Added e2d support to maetieral2
1 parent ce808d9 commit d166b65

File tree

4 files changed

+44
-62
lines changed

4 files changed

+44
-62
lines changed

addon/ng2/models/webpack-build-development.ts

+5-24
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ngAppResolve } from './webpack-build-utils';
44

55
const webpackMerge = require('webpack-merge');
66

7-
export const webpackDevConfig = webpackMerge(webpackCommonConfig, {
7+
const devConfigPartial = {
88
debug: true,
99
devtool: 'cheap-module-source-map',
1010
output: {
@@ -26,28 +26,9 @@ export const webpackDevConfig = webpackMerge(webpackCommonConfig, {
2626
clearImmediate: false,
2727
setImmediate: false
2828
}
29-
});
29+
}
3030

31-
export const webpackDevMaterialConfig = webpackMerge(webpackMaterialConfig, {
32-
debug: true,
33-
devtool: 'cheap-module-source-map',
34-
output: {
35-
path: ngAppResolve('./dist'),
36-
filename: '[name].bundle.js',
37-
sourceMapFilename: '[name].map',
38-
chunkFilename: '[id].chunk.js'
39-
},
40-
tslint: {
41-
emitErrors: false,
42-
failOnHint: false,
43-
resourcePath: ngAppResolve('./src')
44-
},
45-
node: {
46-
global: 'window',
47-
crypto: 'empty',
48-
process: true,
49-
module: false,
50-
clearImmediate: false,
51-
setImmediate: false
52-
}
31+
export const webpackDevConfig = webpackMerge(webpackCommonConfig, devConfigPartial);
32+
33+
export const webpackDevMaterialConfig = webpackMerge(webpackMaterialConfig, devConfigPartial);
5334
});

addon/ng2/models/webpack-build-material2.ts

+28-34
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
// Angular Material2 Custom CLI Webpack Plugin: This allows for the following:
2+
// To build, serve, and watchmode the angular2-material repo.
3+
//
4+
// Requirements:
5+
//
6+
// Do a find and replace on the src directory
7+
// .css'] => .scss']
8+
// This allows for angular2-template-loader to transpile the sass correctly.
9+
110
import * as webpack from 'webpack';
211
import {ngAppResolve} from './webpack-build-utils';
312

@@ -26,7 +35,7 @@ var components = [
2635
'toolbar'
2736
];
2837
/** Map relative paths to URLs. */
29-
var aliasMap = {
38+
var aliasMap: any = {
3039
'@angular2-material/core': ngAppResolve('./src/core'),
3140
};
3241

@@ -39,33 +48,20 @@ export const webpackMaterialConfig = {
3948
devtool: 'inline-source-map',
4049
resolve: {
4150
extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js', '.css', '.scss'],
42-
//SAVE: TODO# Don't use relative bp
4351
root: ngAppResolve('./'),
44-
// modulesDirectory: [
45-
// ngAppResolve('./src/demo-app/'),
46-
// ngAppResolve('./src/core'),
47-
// ngAppResolve('./src/components'),
48-
// 'src/components/',
49-
// 'src/core/'
50-
// ]
5152
alias: aliasMap
5253
},
5354
sassLoader: {
5455
includePaths: [
55-
ngAppResolve('./src/demo-app/style')
56+
// This allows for automatic resolving of @import's for sass for variables.
57+
ngAppResolve('./src/core/style')
5658
]
5759
},
5860
debug: true,
5961
context: path.resolve(__dirname, './'),
60-
//SAVE entry: {
61-
// main: [ngAppResolve('./src/main.ts')],
62-
// vendor: ngAppResolve('./src/vendor.ts'),
63-
// polyfills: ngAppResolve('./src/polyfills.ts')
64-
// },
6562
entry: {
6663
main: [ngAppResolve('./src/demo-app/main.ts')],
6764
vendor: ngAppResolve('./src/demo-app/vendor.ts')
68-
// main: ngAppResolve('./src/e2e-app/main.ts')
6965
},
7066
output: {
7167
path: './dist',
@@ -103,25 +99,23 @@ export const webpackMaterialConfig = {
10399
]
104100
},
105101
plugins: [
106-
// new webpack.NormalModuleReplacementPlugin(/@angular2-material\/core/, require.resolve(ngAppResolve('./src/core/core.ts'))),
107-
// new webpack.NormalModuleReplacementPlugin(/@angular2-material\//, ngAppResolve('./src/components')),
108-
new DebugWebpackPlugin({
109-
// Defaults to ['webpack:*'] which can be VERY noisy, so try to be specific
110-
// scope: [
111-
// 'webpack:compiler:*', // include compiler logs
112-
// 'webpack:plugin:ExamplePlugin' // include a specific plugin's logs
113-
// ],
102+
// new DebugWebpackPlugin({
103+
// // Defaults to ['webpack:*'] which can be VERY noisy, so try to be specific
104+
// // scope: [
105+
// // 'webpack:compiler:*', // include compiler logs
106+
// // 'webpack:plugin:ExamplePlugin' // include a specific plugin's logs
107+
// // ],
114108

115-
// // Inspect the arguments passed to an event
116-
// // These are triggered on emits
117-
// listeners: {
118-
// 'webpack:compiler:run': function(compiler) {
119-
// // Read some data out of the compiler
120-
// }
121-
// },
122-
// Defaults to the compiler's setting
123-
debug: true
124-
}),
109+
// // // Inspect the arguments passed to an event
110+
// // // These are triggered on emits
111+
// // listeners: {
112+
// // 'webpack:compiler:run': function(compiler) {
113+
// // // Read some data out of the compiler
114+
// // }
115+
// // },
116+
// // Defaults to the compiler's setting
117+
// debug: true
118+
// }),
125119
new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}),
126120
new ForkCheckerPlugin(),
127121
new HtmlWebpackPlugin({

addon/ng2/models/webpack-build-production.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import * as webpack from 'webpack';
22
import {webpackCommonConfig} from '../models/';
3+
import { webpackMaterialConfig } from './webpack-build-material2';
34
import {ngAppResolve} from '../models/webpack-build-utils';
45

5-
66
const webpackMerge = require('webpack-merge'); // used to merge webpack configs
77
const WebpackMd5Hash = require('webpack-md5-hash');
88
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin'); //TODO WP2 Typings
99
const CompressionPlugin = require("compression-webpack-plugin");
1010

11+
12+
13+
14+
15+
export const webpackProdMaterialConfig = webpackMerge(webpackCommonConfig, webpackMaterialConfig);
16+
1117
export const webpackProdConfig = webpackMerge(webpackCommonConfig, {
1218
debug: false,
1319
devtool: 'source-map',

addon/ng2/tasks/serve-webpack.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {webpackCommonConfig, webpackOutputOptions} from '../models/';
1+
import {webpackCommonConfig, webpackOutputOptions, webpackDevMaterialConfig, webpackProdMaterialConfig} from '../models/';
22
import {ServeTaskOptions} from '../commands/serve';
33

44
const path = require('path');
@@ -17,8 +17,9 @@ let lastHash = null;
1717
module.exports = Task.extend({
1818
run: (commandOptions: ServeTaskOptions) => {
1919

20-
webpackCommonConfig.entry.main.unshift(`webpack-dev-server/client?http://localhost:${commandOptions.port}/`);
21-
const webpackCompiler = webpack(webpackCommonConfig);
20+
webpackProdMaterialConfig.entry.main.unshift(`webpack-dev-server/client?http://localhost:${commandOptions.port}/`);
21+
22+
const webpackCompiler = webpack(webpackProdMaterialConfig);
2223

2324
webpackCompiler.apply(new ProgressPlugin({
2425
profile: true,

0 commit comments

Comments
 (0)