Skip to content

Commit 91adadb

Browse files
committed
separated additional files for material2
1 parent 5c3067f commit 91adadb

File tree

4 files changed

+57
-61
lines changed

4 files changed

+57
-61
lines changed

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

+18-55
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,14 @@ export const webpackCommonConfig = {
1111
devtool: 'inline-source-map',
1212
resolve: {
1313
extensions: ['', '.ts', '.js'],
14-
//SAVE: TODO# Don't use relative bp
15-
root: ngAppResolve('/src/demo-app'),
16-
alias: {
17-
"@angular2-material/core": ngAppResolve('./src/core'),
18-
"@angular2-material": ngAppResolve('./src/components')
19-
}
14+
root: ngAppResolve('./src')
2015
},
2116
debug: true,
2217
context: path.resolve(__dirname, './'),
23-
//SAVE entry: {
24-
// main: [ngAppResolve('./src/main.ts')],
25-
// vendor: ngAppResolve('./src/vendor.ts'),
26-
// polyfills: ngAppResolve('./src/polyfills.ts')
27-
// },
2818
entry: {
29-
main: [ngAppResolve('./src/demo-app/main.ts')],
30-
// core: ngAppResolve('./src/core/core.ts'),
31-
// main: ngAppResolve('./src/e2e-app/main.ts')
19+
main: [ngAppResolve('./src/main.ts')],
20+
vendor: ngAppResolve('./src/vendor.ts'),
21+
polyfills: ngAppResolve('./src/polyfills.ts')
3222
},
3323
output: {
3424
path: ngAppResolve('./dist'),
@@ -52,13 +42,11 @@ export const webpackCommonConfig = {
5242
{
5343
loader: 'awesome-typescript-loader',
5444
query: {
55-
// useWebpackText: true,
56-
tsconfig: ngAppResolve('./src/demo-app/tsconfig.json'),
57-
// SAVE tsconfig: ngAppResolve('./src/tsconfig.json'),
45+
tsconfig: ngAppResolve('./src/tsconfig.json'),
5846
// resolveGlobs: false,
5947
module: "es2015",
6048
target: "es5",
61-
// library: 'es6',
49+
library: 'es6',
6250
useForkChecker: true
6351
}
6452
},
@@ -78,46 +66,21 @@ export const webpackCommonConfig = {
7866
]
7967
},
8068
plugins: [
81-
new CopyWebpackPlugin([
82-
{from: ngAppResolve('./src/core'), to: ngAppResolve('./dist/core')}
83-
{from: ngAppResolve('./src/components'), to: ngAppResolve('./dist/components')}
84-
]),
85-
new DebugWebpackPlugin({
86-
// Defaults to ['webpack:*'] which can be VERY noisy, so try to be specific
87-
// scope: [
88-
// 'webpack:compiler:*', // include compiler logs
89-
// 'webpack:plugin:ExamplePlugin' // include a specific plugin's logs
90-
// ],
91-
92-
// // Inspect the arguments passed to an event
93-
// // These are triggered on emits
94-
// listeners: {
95-
// 'webpack:compiler:run': function(compiler) {
96-
// // Read some data out of the compiler
97-
// }
98-
// },
99-
// Defaults to the compiler's setting
100-
debug: true;
101-
})
10269
new ForkCheckerPlugin(),
103-
//SAVE new HtmlWebpackPlugin({
104-
// template: ngAppResolve('src/index.html'),
105-
// chunksSortMode: 'dependency'
106-
// }),
10770
new HtmlWebpackPlugin({
108-
template: ngAppResolve('./src/demo-app/index.html'),
71+
template: ngAppResolve('src/index.html'),
72+
chunksSortMode: 'dependency'
73+
}),
74+
new webpack.optimize.CommonsChunkPlugin({
75+
name: ['polyfills', 'vendor'].reverse()
76+
}),
77+
new webpack.optimize.CommonsChunkPlugin({
78+
minChunks: Infinity,
79+
name: 'inline',
80+
filename: 'inline.js',
81+
sourceMapFilename: 'inline.map'
10982
}),
110-
// new webpack.optimize.CommonsChunkPlugin('core'),
111-
//SAVE new webpack.optimize.CommonsChunkPlugin({
112-
// name: ['polyfills', 'vendor'].reverse()
113-
// }),
114-
// new webpack.optimize.CommonsChunkPlugin({
115-
// minChunks: Infinity,
116-
// name: 'inline',
117-
// filename: 'inline.js',
118-
// sourceMapFilename: 'inline.map'
119-
// })
120-
// new CopyWebpackPlugin([{from: ngAppResolve('./public'), to: ngAppResolve('./dist/public')}])
83+
new CopyWebpackPlugin([{from: ngAppResolve('./public'), to: ngAppResolve('./dist/public')}])
12184
],
12285
node: {
12386
global: 'window',

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

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { webpackCommonConfig } from './webpack-build-common';
1+
import { webpackCommonConfig } from '../models';
2+
import { webpackMaterialConfig } from './webpack-build-material2';
23
import { ngAppResolve } from './webpack-build-utils';
34

45
const webpackMerge = require('webpack-merge');
@@ -26,3 +27,27 @@ export const webpackDevConfig = webpackMerge(webpackCommonConfig, {
2627
setImmediate: false
2728
}
2829
});
30+
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+
}
53+
});

addon/ng2/tasks/build-webpack-watch.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
import {webpackOutputOptions, webpackDevConfig, webpackProdConfig} from '../models/';
1+
import {webpackOutputOptions, webpackDevConfig, webpackProdConfig, webpackDevMaterialConfig} from '../models/';
22

33
import {ServeTaskOptions} from '../commands/serve';
44

55
const Task = require('ember-cli/lib/models/task');
66
const webpack = require('webpack');
7+
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
78

89
let lastHash: any = null;
910

1011
module.exports = Task.extend({
1112
run: (runTaskOptions: ServeTaskOptions) => {
13+
let config;
1214

13-
const webpackCompiler = webpack(webpackDevConfig);
14-
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
15+
//TODO# Remove after testing material
16+
if (runTaskOptions.environment === 'material') {
17+
config = webpackDevMaterialConfig;
18+
} else {
19+
config = webpackDevConfig;
20+
}
21+
22+
const webpackCompiler = webpack(config);
1523

1624
webpackCompiler.apply(new ProgressPlugin({
1725
profile: true

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@angular/compiler-cli": "^0.2.0",
3434
"@types/webpack": "^1.12.22-alpha",
3535
"angular2-template-loader": "^0.4.0",
36-
"awesome-typescript-loader": "^1.0.0",
36+
"awesome-typescript-loader": "^2.0.0-rc.3",
3737
"babel-core": "^6.9.1",
3838
"babel-loader": "^6.2.4",
3939
"babel-preset-es2015-webpack": "^6.4.1",
@@ -93,7 +93,7 @@
9393
"tslint": "^3.11.0",
9494
"tslint-loader": "^2.1.4",
9595
"typedoc": "^0.4.2",
96-
"typescript": "^1.9.0-dev.20160616-1.0",
96+
"typescript": "^1.9.0-dev.20160620-1.0",
9797
"typings": "^0.8.1",
9898
"url-loader": "^0.5.7",
9999
"webpack": "2.1.0-beta.13",

0 commit comments

Comments
 (0)