Skip to content

Commit 0184243

Browse files
committed
Added fastcss web pack
1 parent 9b762c6 commit 0184243

22 files changed

+140
-80097
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
package/node_modules
22
test-app/node_modules
3+
npm-debug.log

test-app/gulpfile.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
'use strict';
2+
3+
var gulp = require('gulp');
4+
var path = require('path');
5+
var sourcemaps = require('gulp-sourcemaps');
6+
var sass = require('gulp-sass');
7+
var gutil = require('gulp-util');
8+
var http = require("http");
9+
var replace = require('gulp-replace');
10+
11+
/**
12+
* Common implementation for an error handler of a Gulp plugin
13+
*/
14+
var errorHandler = function (title) {
15+
'use strict';
16+
17+
return function (err) {
18+
gutil.log(gutil.colors.red('[' + title + ']'), err.toString());
19+
this.emit('end');
20+
};
21+
};
22+
23+
gulp.task('styles', function () {
24+
return buildStyles();
25+
});
26+
27+
var buildStyles = function () {
28+
var sassOptions = {
29+
style: 'expanded',
30+
includePaths: ['node_modules/']
31+
};
32+
33+
return gulp.src([
34+
path.join(__dirname, '/src/app/style.scss')
35+
])
36+
.pipe(sourcemaps.init())
37+
.pipe(replace('~ionic-sdk/release/fonts', 'fonts'))
38+
.pipe(replace('~', 'node_modules/'))
39+
.pipe(sass(sassOptions)).on('error', errorHandler('Sass'))
40+
.pipe(sourcemaps.write())
41+
.pipe(gulp.dest(path.join(__dirname, '/www/')));
42+
};
43+
44+
gulp.task('styles:reload', ['styles'], function(done) {
45+
http.get({
46+
hostname: 'localhost',
47+
port: 8080,
48+
path: '/__browser_sync__?method=reload&args=style.css',
49+
agent: false // create a new agent just for this one request
50+
}, function (res) {
51+
done();
52+
});
53+
});
54+
55+
gulp.task('copy:fonts', function() {
56+
return gulp.src('node_modules/ionic-sdk/release/fonts/*')
57+
.pipe(gulp.dest('www/fonts'));
58+
});
59+
60+
gulp.task('copy:assets', function() {
61+
return gulp.src('src/app/asset*/**/*')
62+
.pipe(gulp.dest('www'));
63+
});
64+
65+
gulp.task('watch', ['styles', 'copy:assets', 'copy:fonts'], function () {
66+
67+
gulp.watch([
68+
path.join(__dirname, '/src/app/**/*.scss')
69+
], function (event) {
70+
gulp.start('styles:reload');
71+
});
72+
});

test-app/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"scripts": {
77
"build:dev": "webpack --config webpack.development.config.js --env development",
88
"build:production": "webpack --config webpack.production.config.js --env production",
9+
"serve:fastcss": "npm-run-all --parallel fastcss webpack:watch",
10+
"webpack:watch": "webpack --config webpack.fastcss.config.js --watch --env development",
11+
"fastcss": "gulp watch",
912
"serve": "webpack --config webpack.development.config.js --watch --env development",
1013
"serve:production": "webpack --config webpack.production.config.js --watch --env production"
1114
},
@@ -21,13 +24,15 @@
2124
"css-loader": "0.14.5",
2225
"extract-text-webpack-plugin": "^1.0.1",
2326
"file-loader": "^0.9.0",
27+
"gulp": "^3.9.1",
2428
"html-loader": "^0.4.3",
2529
"html-webpack-plugin": "^2.21.0",
2630
"imports-loader": "^0.6.5",
2731
"json-loader": "^0.5.4",
2832
"lodash": "^4.14.0",
2933
"ng-annotate-webpack-plugin": "^0.1.3",
3034
"node-sass": "^3.8.0",
35+
"npm-run-all": "^3.0.0",
3136
"postcss-loader": "^0.10.1",
3237
"raw-loader": "^0.5.1",
3338
"sass-loader": "^4.0.0",

test-app/src/app/index.web.html renamed to test-app/src/app/index.fastcss.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<!doctype html>
2-
<html ng-app="testApp">
2+
<html>
33
<head>
44
<meta charset="utf-8">
55
<title>Test App</title>
66
<meta name="description" content="">
77
<meta name="viewport" content="width=device-width">
88
<meta name="format-detection" content="telephone=no">
99
<meta http-equiv="Content-Security-Policy" content="default-src * data:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
10-
<script src="home/client-config.js"></script>
10+
<link rel="stylesheet" type="text/css" href="style.css">
1111
</head>
1212
<body>
1313
<ion-nav-view></ion-nav-view>

test-app/src/app/index.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {MainController} from './views/main/MainController.ts';
1212
import {Config} from './index.config.ts';
1313
import {RouterConfig} from './index.route.ts';
1414
import {RunBlock} from './index.run.ts';
15-
import {loadConfigurationJSON} from "gl-angular-configuration/package/src/ConfigurationProvider";
15+
import {loadConfigurationJSON} from "gl-angular-configuration/package/src/ConfigurationProvider.ts";
1616

1717
exports = angular.module('testApp', [
1818
'ionic',

test-app/webpack.base.config.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
'use strict';
66

7-
var HtmlWebpackPlugin = require('html-webpack-plugin');
87
var ExtractTextPlugin = require("extract-text-webpack-plugin");
98
var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
109
var CopyWebpackPlugin = require('copy-webpack-plugin');
@@ -25,8 +24,7 @@ for (var i = 0; i < process.argv.length; i++) {
2524
module.exports = {
2625
entry: {
2726
app: [
28-
'./src/app/index.module.ts',
29-
'./src/app/style.scss'
27+
'./src/app/index.module.ts'
3028
]
3129
},
3230
output: {
@@ -49,12 +47,6 @@ module.exports = {
4947
to: path.join(__dirname, "www/configuration.json")
5048
}
5149
]),
52-
new HtmlWebpackPlugin({
53-
pkg: require('./package.json'),
54-
template: path.join(__dirname, 'src/app/index.cordova.html'),
55-
inject: 'body',
56-
hash: true
57-
}),
5850
new BrowserSyncPlugin({
5951
host: 'localhost',
6052
port: 8080,

test-app/webpack.development.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var utils = require('./webpack.utils');
88

99
var ExtractTextPlugin = require("extract-text-webpack-plugin");
1010

11-
module.exports = utils.config({
11+
module.exports = utils.configNoFastcss({
1212
devtool: 'source-map',
1313
module: {
1414
loaders: [{

test-app/webpack.fastcss.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Created by Vidailhet on 28/07/16.
3+
*/
4+
5+
'use strict';
6+
7+
var utils = require('./webpack.utils');
8+
9+
var HtmlWebpackPlugin = require('html-webpack-plugin');
10+
11+
var path = require('path');
12+
13+
module.exports = utils.config({
14+
plugins: [
15+
new HtmlWebpackPlugin({
16+
pkg: require('./package.json'),
17+
template: path.join(__dirname, 'src/app/index.fastcss.html'),
18+
inject: 'body',
19+
hash: true
20+
})
21+
]
22+
});
23+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Created by Vidailhet on 28/07/16.
3+
*/
4+
5+
'use strict';
6+
7+
var utils = require('./webpack.utils');
8+
9+
var HtmlWebpackPlugin = require('html-webpack-plugin');
10+
11+
var path = require('path');
12+
13+
module.exports = {
14+
entry: {
15+
app: [
16+
'./src/app/style.scss'
17+
]
18+
},
19+
plugins: [
20+
new HtmlWebpackPlugin({
21+
pkg: require('./package.json'),
22+
template: path.join(__dirname, 'src/app/index.cordova.html'),
23+
inject: 'body',
24+
hash: true
25+
})]
26+
};
27+

test-app/webpack.production.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var autoprefixer = require('autoprefixer');
1212
var ngAnnotatePlugin = require('ng-annotate-webpack-plugin');
1313
var ExtractTextPlugin = require("extract-text-webpack-plugin");
1414

15-
module.exports = utils.config({
15+
module.exports = utils.configNoFastcss({
1616
plugins: [
1717
new ngAnnotatePlugin({
1818
add: true

0 commit comments

Comments
 (0)