1
1
const Command = require ( 'ember-cli/lib/models/command' ) ;
2
2
const win = require ( 'ember-cli/lib/utilities/windows-admin' ) ;
3
- const path = require ( 'path' ) ;
4
-
5
- const Build = require ( '../tasks/build' ) ;
6
- const BuildWatch = require ( '../tasks/build-watch' ) ;
7
3
4
+ // const Build = require('../tasks/build');
5
+ // const BuildWatch = require('../tasks/build-watch');
8
6
7
+ // Webpack Configuration
9
8
const webpack = require ( 'webpack' ) ;
10
-
9
+ const webpackConfig = require ( '../tasks/webpack-build-config' ) ;
10
+ const webpackCompiler = webpack ( webpackConfig ) ;
11
11
12
12
module . exports = Command . extend ( {
13
13
name : 'build' ,
@@ -23,76 +23,19 @@ module.exports = Command.extend({
23
23
] ,
24
24
25
25
run : function ( commandOptions ) {
26
- // var BuildTask = this.taskFor(commandOptions);
27
- // var buildTask = new BuildTask({
28
- // ui: this.ui,
29
- // analytics: this.analytics,
30
- // project: this.project
31
- // });
32
- // var ShowAssetSizesTask = this.tasks.ShowAssetSizes;
33
- // var showTask = new ShowAssetSizesTask({
34
- // ui: this.ui
35
- // });
36
- //
37
- // return win.checkWindowsElevation(this.ui).then(function () {
38
- // return buildTask.run(commandOptions)
39
- // .then(function () {
40
- // if (!commandOptions.suppressSizes && commandOptions.environment === 'production') {
41
- // return showTask.run({
42
- // outputPath: commandOptions.outputPath
43
- // });
44
- // }
45
- // });
46
- // });
47
-
48
-
49
- return new Promise ( ( resolve ) => {
50
- webpack ( {
51
- resolve : {
52
- extensions : [ '' , '.css' , '.scss' , '.ts' , '.js' ]
53
- } ,
54
-
55
- plugins : [
56
- // new LiveReloadPlugin({
57
- // appendScriptTag: true
58
- // })
59
- ] ,
60
-
61
- entry : path . resolve ( process . cwd ( ) , './src/main.ts' ) ,
62
- output : {
63
- path : "./dist" ,
64
- publicPath : 'dist/' ,
65
- filename : "bundle.js"
66
- } ,
67
- ts : {
68
- configFileName : './src/tsconfig.json'
69
- } ,
70
-
71
- // devtool: 'source-map',
72
-
73
- module : {
74
- loaders : [
75
- {
76
- test : / \. t s $ / ,
77
- loader : 'ts-loader'
78
- } ,
79
- {
80
- test : / \. c s s $ / ,
81
- loader : 'style-loader'
82
- }
83
- ]
84
- } ,
85
-
86
- devServer : {
87
- historyApiFallback : true
88
- }
89
- } , function ( err , stats ) {
90
- resolve ( ) ;
91
- console . log ( err ) ;
92
- console . log ( stats ) ;
93
- console . log ( '--------' ) ;
26
+ return new Promise ( ( resolve , reject ) => {
27
+ webpackCompiler . run ( ( err , stats ) => {
28
+ debugger ;
29
+ if ( err || stats . compilation . errors . length ) {
30
+ reject ( stats . compilation . errors ) ;
31
+ console . log ( err ) ;
32
+ }
33
+
34
+ resolve ( ) ;
35
+ console . log ( stats ) ;
36
+ console . log ( '--------' ) ;
37
+ } ) ;
94
38
} ) ;
95
- } ) ;
96
39
} ,
97
40
98
41
taskFor : function ( options ) {
0 commit comments