Permalink
Browse files

feat: use `angular-webpack-config`

  • Loading branch information...
Burak Tasci
Burak Tasci committed Jun 28, 2017
1 parent eee2a22 commit b154fcc96fb1bdc3e047ac7a599f83d08eb6ee0e
@@ -24,6 +24,7 @@ coverage/
!postcss.config.js
!protractor.conf.js
!stylelint.config.js
!webpack.config.js

# misc
!config/*.js
@@ -0,0 +1,28 @@
{
"bitwise": true,
"eqeqeq": true,
"forin": true,
"noarg": true,
"noempty": true,
"nonbsp": true,
"nonew": true,
"undef": true,
"varstmt": true,
"esversion": 6,
"latedef": true,
"unused": true,
"indent": 2,
"quotmark": "single",
"maxcomplexity": 20,
"maxlen": 140,
"maxerr": 50,
"globals": {},
"strict": true,
"laxbreak": true,
"browser": true,
"module": true,
"node": true,
"trailing": true,
"onevar": true,
"white": true
}
@@ -14,7 +14,7 @@ const path = require('path');
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const webpackConfig = require('angular-webpack-config');
const webpackConfig = require($$.root('./config/webpack.config'));

const server = express();
server.use(compression());
@@ -23,7 +23,10 @@ server.use(logger('dev'));
/**
* HMR support
*/
const conf = webpackConfig.spa.hmr($$.root, settings);
const conf = webpackConfig({
env: 'dev',
hmr: true
}, $$.root, settings);
const compiler = webpack(conf);

server.use(webpackDevMiddleware(compiler, {
@@ -13,10 +13,12 @@
"root": "{{root}}/src",
"client": {
"root": "{{src_root}}/client",
"app": "{{src_client_root}}/app",
"app": {
"root": "{{src_client_root}}/app"
},
"assets": {
"root": "{{src_client_root}}/assets",
"sass": "{{src_client_root}}/assets/sass"
"sass": "{{src_assets_root}}/sass"
}
},
"server": {
@@ -26,7 +28,9 @@
},
"public": {
"root": "{{root}}/public",
"assets": "{{public_root}}/assets"
"assets": {
"root": "{{public_root}}/assets"
}
},
"server": "{{root}}/.server",
"cache": "{{root}}/.cache",
@@ -92,11 +96,14 @@
"@angular/platform-browser",
"@angular/platform-browser-dynamic",
"@angular/platform-server",
"@angular/router",
"rxjs",
"@angularclass/bootloader"
"@angular/router"
],
"vendor": [
"core-js",
"rxjs",
"zone.js",
"lodash",
"@angularclass/bootloader",
"@ngx-universal/express-engine",
"@ngx-universal/state-transfer",
"@ngx-config/core",
@@ -192,8 +192,8 @@ const webpackFormatter = function(err, stats, callback, settings) {

console.log(`Webpack: ${$.chalk.blue(`finished`)}`);

if (!!settings && !!settings.paths && !!settings.paths.public && !!settings.paths.public.assets)
require('fs').writeFileSync($$.root(`${settings.paths.public.assets}/stats.json`), JSON.stringify(statsJson));
if (!!settings && !!settings.paths && !!settings.paths.public && !!settings.paths.public.assets && !!settings.paths.public.assets.root)
require('fs').writeFileSync($$.root(`${settings.paths.public.assets.root}/stats.json`), JSON.stringify(statsJson));

callback();
}
@@ -9,7 +9,7 @@ const gulp = require('gulp'),
$ = require('gulp-load-plugins')(settings.plugins.pluginloader),
$$ = require('./gulp-helpers');

$.webpackConfig = require('angular-webpack-config');
$.webpackConfig = require('./webpack.config');
settings = $$.loadSettings(settings);

/**
@@ -34,7 +34,7 @@ const clean = {
$.rimraf(`${settings.paths.public.root}/**`, done);
},
artifacts: function(done) {
$.rimraf(`${settings.paths.public.assets}/index.html`, done);
$.rimraf(`${settings.paths.public.assets.root}/index.html`, done);
},
server: function(done) {
$.rimraf(`${settings.paths.server}/server*.*`, done);
@@ -88,7 +88,6 @@ const assets = {
clearReportedMessages: true
})
];
const path = '/components';

gulp.src(`${settings.paths.src.client.assets.sass}/**/*.scss`)
.pipe($$.sass({sourcemaps: true}))
@@ -125,7 +124,7 @@ assets.sass.lib.refactor.displayName = 'stylefmt:sass-lib';
const views = {
assets: {
copy: function(done) {
gulp.src(`${settings.paths.public.assets}/index.html`)
gulp.src(`${settings.paths.public.assets.root}/index.html`)
.pipe($$.changed(settings, settings.paths.public.root))
.pipe(gulp.dest(settings.paths.public.root))
.pipe($$.debug(settings))
@@ -155,15 +154,15 @@ ts.lint.displayName = 'lint:ts';
const bundle = {
spa: {
dev: function(done) {
const conf = $.webpackConfig.spa.dev($$.root, settings);
const conf = $.webpackConfig({ env: 'dev' }, $$.root, settings);

$.webpack(conf)
.run(function(err, stats) {
$$.webpackFormatter(err, stats, done);
});
},
prod: function(done) {
const conf = $.webpackConfig.spa.prod($$.root, settings);
const conf = $.webpackConfig({ env: 'prod' }, $$.root, settings);

$.webpack(conf)
.run(function(err, stats) {
@@ -174,15 +173,21 @@ const bundle = {
universal: {
browser: {
dev: function(done) {
const conf = $.webpackConfig.universal.browser.dev($$.root, settings);
const conf = $.webpackConfig({
env: 'dev',
platform: 'browser'
}, $$.root, settings);

$.webpack(conf)
.run(function(err, stats) {
$$.webpackFormatter(err, stats, done);
});
},
prod: function(done) {
const conf = $.webpackConfig.universal.browser.prod($$.root, settings);
const conf = $.webpackConfig({
env: 'prod',
platform: 'browser'
}, $$.root, settings);

$.webpack(conf)
.run(function(err, stats) {
@@ -192,15 +197,21 @@ const bundle = {
},
server: {
dev: function(done) {
const conf = $.webpackConfig.universal.server.dev($$.root, settings);
const conf = $.webpackConfig({
env: 'dev',
platform: 'server'
}, $$.root, settings);

$.webpack(conf)
.run(function(err, stats) {
$$.webpackFormatter(err, stats, done);
});
},
prod: function(done) {
const conf = $.webpackConfig.universal.server.prod($$.root, settings);
const conf = $.webpackConfig({
env: 'prod',
platform: 'server'
}, $$.root, settings);

$.webpack(conf)
.run(function(err, stats) {
@@ -24,14 +24,19 @@ const loadSettings = function(settings) {
result = $.jsonSub.substituteSync(result, {
'{{src_root}}': result.paths.src.root,
'{{public_root}}': result.paths.public.root,
'{{temp_root}}': result.paths.temp.root,
'{{temp_root}}': result.paths.temp.root
});

result = $.jsonSub.substituteSync(result, {
'{{src_server_root}}': result.paths.src.server.root,
'{{src_client_root}}': result.paths.src.client.root
});

result = $.jsonSub.substituteSync(result, {
'{{src_assets_root}}': result.paths.src.client.assets.root,
'{{public_assets_root}}': result.paths.public.assets.root
});

return result;
};

@@ -1,7 +1,14 @@
/**
* Dependencies
*/
const webpackConfig = require('./webpack.test.js');
let settings = require('./build-config.json');

const $$ = require('./gulp-helpers'),
webpackConfig = require('./webpack.config');

settings = $$.loadSettings(settings);

const conf = webpackConfig({ env: 'test' }, $$.root, settings);

module.exports = function(config) {
const configuration = {
@@ -39,7 +46,7 @@ module.exports = function(config) {
'./config/spec-bundle.js': ['coverage', 'webpack', 'sourcemap']
},

webpack: webpackConfig,
webpack: conf,

// webpack please don't spam the console when running in karma!
webpackMiddleware: {

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit b154fcc

Please sign in to comment.