Skip to content

Commit 1b4a911

Browse files
committed
Added all the plim things that needed to be added. Tests still fail but I think I'm on my way
1 parent 55920f5 commit 1b4a911

File tree

5 files changed

+136
-183
lines changed

5 files changed

+136
-183
lines changed

addon/ng2/commands/test.js

+31-30
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
var Promise = require('ember-cli/lib/ext/promise');
44
var TestCommand = require('ember-cli/lib/commands/test');
55
var win = require('ember-cli/lib/utilities/windows-admin');
6-
var BuildTask = require('ember-cli/lib/tasks/build');
7-
var BuildWatchTask = require('ember-cli/lib/tasks/build-watch');
6+
// var BuildTask = require('ember-cli/lib/tasks/build');
7+
// var BuildWatchTask = require('ember-cli/lib/tasks/build-watch');
8+
const BuildWebpack = require('../tasks/build-webpack');
9+
const BuildWebpackWatch = require('../tasks/build-webpack-watch');
810
const config = require('../models/config');
9-
var TestTask = require('../tasks/test');
11+
const TestTask = require('../tasks/test');
1012

1113

1214
module.exports = TestCommand.extend({
@@ -23,58 +25,57 @@ module.exports = TestCommand.extend({
2325
run: function (commandOptions) {
2426
this.project.ngConfig = this.project.ngConfig || config.CliConfig.fromProject();
2527

26-
var buildWatchTask =
27-
new BuildWatchTask({
28-
ui: this.ui,
29-
analytics: this.analytics,
30-
project: this.project
31-
});
32-
var buildTask = new BuildTask({
33-
ui: this.ui,
34-
analytics: this.analytics,
35-
project: this.project
36-
});
28+
// var buildWatchTask =
29+
// new BuildWebpackWatch({
30+
// ui: this.ui,
31+
// analytics: this.analytics,
32+
// project: this.project
33+
// });
34+
// var buildTask = new BuildWebpack({
35+
// ui: this.ui,
36+
// analytics: this.analytics,
37+
// project: this.project
38+
// });
3739
var testTask = new TestTask({
3840
ui: this.ui,
3941
analytics: this.analytics,
4042
project: this.project
4143
});
42-
4344
var buildOptions = {
4445
environment: 'development',
4546
outputPath: 'dist/'
4647
};
47-
48+
4849
// If not building, mock/suppress build tasks.
49-
if (!commandOptions.build) {
50-
buildTask = {
51-
run: () => {
52-
return;
53-
}
54-
};
55-
buildWatchTask = buildTask;
56-
}
57-
50+
// if (!commandOptions.build) {
51+
// buildTask = {
52+
// run: () => {
53+
// return;
54+
// }
55+
// };
56+
// buildWatchTask = buildTask;
57+
// }
58+
5859
if (commandOptions.watch) {
5960
return win.checkWindowsElevation(this.ui)
6061
.then(
6162
() => {
6263
// perform initial build to avoid race condition
63-
return buildTask.run(buildOptions);
64+
// return buildTask.run(buildOptions);
6465
},
6566
() => {
6667
/* handle build error to allow watch mode to start */
6768
})
6869
.then(() => {
69-
return Promise.all([buildWatchTask.run(buildOptions), testTask.run(commandOptions)]);
70+
return Promise.all([testTask.run(commandOptions)]);
7071
});
7172
} else {
7273
// if not watching ensure karma is doing a single run
7374
commandOptions.singleRun = true;
7475
return win.checkWindowsElevation(this.ui)
75-
.then(() => {
76-
return buildTask.run(buildOptions);
77-
})
76+
// .then(() => {
77+
// return buildTask.run(buildOptions);
78+
// })
7879
.then(() => {
7980
return testTask.run(commandOptions);
8081
});

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

+83-62
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const ClosureCompilerPlugin = require('webpack-closure-compiler');
66
const autoprefixer = require('autoprefixer');
77
const cssnano = require('cssnano');
88
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
9+
const webpackMerge = require('webpack-merge');
910

1011
// Resolve to the generated applications
1112
function ngAppResolve(resolvePath: string): string {
@@ -18,34 +19,77 @@ let baseHtmlTemplateConfig = {
1819
};
1920

2021
// These are the output
21-
export const webpackOutputOptions = {
22+
export const webpackOutputOptions: WebpackProgressPluginOutputOptions = {
2223
colors: true,
2324
chunks: true,
2425
modules: false,
2526
reasons: false,
2627
chunkModules: false
2728
}
2829

29-
export interface IWebpackDevServerConfigurationOptions {
30-
contentBase?: string;
31-
hot?: boolean;
32-
historyApiFallback?: boolean;
33-
compress?: boolean;
34-
proxy?: {[key: string] : string};
35-
staticOptions?: any;
36-
quiet?: boolean;
37-
noInfo?: boolean;
38-
lazy?: boolean;
39-
filename?: string;
40-
watchOptions?: {
41-
aggregateTimeout?: number;
42-
poll?: number;
30+
const webpackTestPartial = {
31+
module: {
32+
plugins: [
33+
new ForkCheckerPlugin(),
34+
new HtmlWebpackPlugin(baseHtmlTemplateConfig),
35+
],
36+
preLoaders: [
37+
{
38+
test: /\.ts$/,
39+
loader: 'tslint-loader',
40+
exclude: ['node_modules']
41+
},
42+
{
43+
test: /\.js$/,
44+
loader: 'source-map-loader',
45+
exclude: [
46+
// these packages have problems with their sourcemaps
47+
ngAppResolve('node_modules/rxjs'),
48+
ngAppResolve('node_modules/@angular')
49+
]}
50+
],
51+
loaders: [
52+
{
53+
test: /\.ts$/,
54+
loaders: [
55+
{
56+
loader: 'awesome-typescript-loader',
57+
query: {
58+
useWebpackText: true,
59+
tsconfig: ngAppResolve('./src/tsconfig.json'),
60+
resolveGlobs: false,
61+
module: "es2015",
62+
target: "es5",
63+
library: 'es6',
64+
useForkChecker: true,
65+
removeComments: true
66+
}
67+
},
68+
{
69+
loader: 'angular2-template-loader'
70+
}
71+
],
72+
exclude: [/\.(spec|e2e)\.ts$/]
73+
},
74+
{ test: /\.json$/, loader: 'json-loader', exclude: [ngAppResolve('src/index.html')] },
75+
{ test: /\.css$/, loader: 'raw-loader', exclude: [ngAppResolve('src/index.html')] },
76+
{ test: /\.html$/, loader: 'raw-loader', exclude: [ngAppResolve('src/index.html')] }
77+
]
4378
},
44-
publicPath?: string;
45-
headers?: { [key:string]: string };
46-
stats?: { colors: boolean; };
47-
inline: boolean;
48-
}
79+
tslint: {
80+
emitErrors: false,
81+
failOnHint: false,
82+
resourcePath: 'src'
83+
},
84+
node: {
85+
global: 'window',
86+
process: false,
87+
crypto: 'empty',
88+
module: false,
89+
clearImmediate: false,
90+
setImmediate: false
91+
}
92+
};
4993

5094
// Webpack Configuration Object
5195
// Used in build.ts
@@ -62,20 +106,12 @@ export const webpackCommonConfig = {
62106
path: ngAppResolve('./dist'),
63107
filename: '[name].bundle.js'
64108
},
65-
devtool: 'cheap-module-source-map',
109+
devtool: 'sourcemap',
66110
module: {
67111
loaders: [
68112
{
69113
test: /\.ts$/,
70114
loaders: [
71-
// {
72-
// loader: 'babel-loader', //TODO: Remove Babel once support for lib: for typescript@next
73-
// query: {
74-
// presets: [
75-
// 'babel-preset-es2015-webpack'
76-
// ].map(require.resolve)
77-
// }
78-
// },
79115
{
80116
loader: 'awesome-typescript-loader',
81117
query: {
@@ -94,37 +130,13 @@ export const webpackCommonConfig = {
94130
],
95131
exclude: [/\.(spec|e2e)\.ts$/]
96132
},
97-
{
98-
test: /\.json$/,
99-
loader: 'json-loader'
100-
},
101-
{
102-
test: /\.css$/,
103-
loaders: ['raw-loader', 'postcss-loader']
104-
},
105-
{
106-
test:/\.styl$/,
107-
loaders: ['raw-loader', 'postcss-loader', 'stylus-loader']
108-
},
109-
{
110-
test:/\.less$/,
111-
loaders: ['raw-loader', 'postcss-loader', 'less-loader']
112-
},
113-
{
114-
test:/\.scss$/,
115-
loaders: ['raw-loader', 'postcss-loader', 'sass-loader']
116-
},
117-
//
118-
// Asset loaders
119-
//
120-
{
121-
test: /\.(jpg|png)$/,
122-
loader: 'url-loader?limit=25000', // Only inline for sizes <= 25000
123-
},
124-
{
125-
test: /\.html$/,
126-
loader: 'raw-loader'
127-
}
133+
{ test: /\.json$/, loader: 'json-loader'},
134+
{ test: /\.css$/, loaders: ['raw-loader', 'postcss-loader'] },
135+
{ test: /\.styl$/, loaders: ['raw-loader', 'postcss-loader', 'stylus-loader'] },
136+
{ test: /\.less$/, loaders: ['raw-loader', 'postcss-loader', 'less-loader'] },
137+
{ test: /\.scss$/, loaders: ['raw-loader', 'postcss-loader', 'sass-loader'] },
138+
{ test: /\.(jpg|png)$/, loader: 'url-loader?limit=128000'},
139+
{ test: /\.html$/, loader: 'raw-loader' }
128140
]
129141
},
130142
postcss: () => {
@@ -134,15 +146,24 @@ export const webpackCommonConfig = {
134146
},
135147
plugins: [
136148
new ForkCheckerPlugin(),
149+
new HtmlWebpackPlugin(baseHtmlTemplateConfig),
137150
new webpack.optimize.CommonsChunkPlugin({
138151
name: ['polyfills', 'vendor'].reverse()
139152
}),
140-
new HtmlWebpackPlugin(baseHtmlTemplateConfig),
141153
new CopyWebpackPlugin([{from: ngAppResolve('./public'), to: ngAppResolve('./dist/public')}])
142154
],
143155
resolve: {
144156
extensions: ['', '.ts', '.js'],
145157
root: ngAppResolve('./src')
146-
// modulesDirectories: ['node_modules']
147158
}
148159
};
160+
161+
export const webpackTestConfig = webpackMerge(webpackTestPartial, webpackCommonConfig);
162+
163+
164+
165+
166+
167+
168+
169+

addon/ng2/models/webpack-karma-config.ts

-90
This file was deleted.

0 commit comments

Comments
 (0)