Skip to content

Commit 77bfe2f

Browse files
committed
fix(build): fix dist build
- disable UglifyJsPlugin mangle - add connect server for serving build / dist folders - add npm server tasks - code cleanup
1 parent 6085ba5 commit 77bfe2f

File tree

7 files changed

+39
-16
lines changed

7 files changed

+39
-16
lines changed

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
"scripts": {
77
"start": "webpack-dev-server --TARGET=DEV",
88
"build": "webpack --display-chunks --display-reasons --display-error-details --display-modules",
9-
"dist": "webpack -p --TARGET=DIST",
10-
"test": "mocha --compilers js:mocha-babel ./src/**/*.test.js"
9+
"dist": "webpack --TARGET=DIST",
10+
"test": "mocha --compilers js:mocha-babel ./src/**/*.test.js",
11+
"server_build": "node server.js",
12+
"server_dist": "node server.js --TARGET=DIST"
1113
},
1214
"author": "tomas.trajan@gmail.com",
1315
"license": "ISC",
@@ -31,6 +33,7 @@
3133
"chai": "^3.2.0",
3234
"chalk": "^1.1.0",
3335
"clean-webpack-plugin": "^0.1.3",
36+
"connect": "^3.4.0",
3437
"css-loader": "^0.15.6",
3538
"file-loader": "^0.8.4",
3639
"html-loader": "^0.3.0",
@@ -39,6 +42,7 @@
3942
"mocha": "^2.2.5",
4043
"mocha-babel": "^3.0.0",
4144
"ngtemplate-loader": "^1.3.0",
45+
"serve-static": "^1.10.0",
4246
"sinon": "^1.17.1",
4347
"style-loader": "^0.12.3",
4448
"typescript": "^1.5.3",

server.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var minimist = require('minimist');
2+
var connect = require('connect');
3+
var serveStatic = require('serve-static');
4+
5+
6+
var PORT = 8080;
7+
var TARGET_PATH_MAPPING = {
8+
BUILD: './build',
9+
DIST: './dist'
10+
};
11+
12+
var TARGET = minimist(process.argv.slice(2)).TARGET || 'BUILD';
13+
14+
connect()
15+
.use(serveStatic(TARGET_PATH_MAPPING[TARGET]))
16+
.listen(PORT);
17+
18+
console.log('Created server for: ' + TARGET + ', listening on port ' + PORT);

src/feature-b/feature-b.config.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ export function routing($stateProvider) {
33
$stateProvider
44
.state('app.feature-b', {
55
url: '/feature-b',
6-
template: '<div todo-component></div>',
7-
resolve: {
8-
initialTodos: function() {
9-
return [];
10-
}
11-
}
6+
template: '<div todo-component></div>'
127
});
138
}

src/feature-b/feature-b.module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import angular from 'angular';
22
import uirouter from 'angular-ui-router';
33

44
import { routing } from './feature-b.config.js';
5-
import { EMPTY_TODOS, DEFAULT_TODOS } from './feature-b.constants.js';
5+
import { DEFAULT_TODOS } from './feature-b.constants.js';
66

77
import todoComponent from './todo-component/todo-component.directive';
88
import TodoService from './services/todo.service';

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>Component Pattern for Angular 1.X</title>
5+
<title>Proper testing of Angular 1.X with ES6 modules</title>
66
<base href="/">
77

88
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">

src/main.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import 'bootstrap/dist/css/bootstrap.min.css';
33
import './main.css';
44

5-
// 3rd party libraries
5+
// 3rd party modules
66
import bootstrap from 'bootstrap';
77
import angular from 'angular';
88
import angularAnimate from 'angular-animate';
@@ -15,7 +15,10 @@ import common from './common/common.module';
1515
import featureA from './feature-a/feature-a.module';
1616
import featureB from './feature-b/feature-b.module';
1717

18-
angular.module('main', [angularAnimate, angularUiBootstrap, angularHighlightjs, app, common, featureA, featureB]);
18+
angular.module('main', [
19+
angularAnimate, angularUiBootstrap, angularHighlightjs,
20+
app, common, featureA, featureB
21+
]);
1922

2023
angular.element(document).ready(function() {
2124
angular.bootstrap(document, ['main']);

webpack.config.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ var paramsPerTarget = {
3737
path: './dist'
3838
},
3939
plugins: [
40-
new CleanWebpackPlugin(['dist'])
40+
new CleanWebpackPlugin(['dist']),
41+
new webpack.optimize.UglifyJsPlugin({
42+
mangle: false
43+
})
4144
]
4245
}
4346
};
@@ -62,7 +65,7 @@ module.exports = {
6265
{test: /\.js$/, loader: 'babel?optional[]=runtime&stage=1', exclude: /(\.test.js$|node_modules)/},
6366
{test: /\.css$/, loader: 'style!css'},
6467
{test: /\.tpl.html/, loader: 'html'},
65-
{test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/, loader: "url?limit=50000"}
68+
{test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/, loader: 'url?limit=50000'}
6669
]
6770
},
6871
plugins: [
@@ -71,8 +74,8 @@ module.exports = {
7174
inject: 'body'
7275
}),
7376
new webpack.ProvidePlugin({
74-
$: "jquery",
75-
jQuery: "jquery"
77+
$: 'jquery',
78+
jQuery: 'jquery'
7679
})
7780
].concat(params.plugins || []),
7881
devServer: {

0 commit comments

Comments
 (0)