Skip to content

Commit

Permalink
feat($app,$config): add initial set of css3 grid config
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Hodges committed Sep 12, 2017
1 parent 46002ff commit 779d2ed
Show file tree
Hide file tree
Showing 24 changed files with 1,247 additions and 181 deletions.
30 changes: 27 additions & 3 deletions config/helpers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
/**
* @author: @JasonHodges
*/
const path = require('path');

const EVENT = process.env.npm_lifecycle_event || '';
/**
* Helper functions
*/
const _root = path.resolve(__dirname, '..');

function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [_root].concat(args));
function hasProcessFlag(flag) {
return process.argv.join('').indexOf(flag) > -1;
}

function hasNpmFlag(flag) {
return EVENT.includes(flag);
}

function isWebpackDevServer() {
return process.argv[1] && !!(/webpack-dev-server/.exec(process.argv[1]));
}

var root = path.join.bind(path, _root);

// function root(args) {
// args = Array.prototype.slice.call(arguments, 0);
// return path.join.apply(path, [_root].concat(args));
// }

exports.hasProcessFlag = hasProcessFlag;
exports.hasNpmFlag = hasNpmFlag;
exports.isWebpackDevServer = isWebpackDevServer;
exports.root = root;
150 changes: 150 additions & 0 deletions config/webpack.common.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
const webpack = require('webpack');
const helpers = require('./helpers');
// const marked = require('marked');
// const times = require('lodash/times');
// const sass = require('node-sass');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const WebpackShellPlugin = require('webpack-shell-plugin');
const LoopMarkdownPlugin = require('../config/LoopMarkdown');


/**
* Webpack Constants
*/
const HMR = helpers.hasProcessFlag('hot');
const AOT = process.env.BUILD_AOT || helpers.hasNpmFlag('aot');
const METADATA = {
title: 'ngx-blog by @JasonHodges',
baseUrl: '/',
isDevServer: helpers.isWebpackDevServer(),
HMR: HMR,
AOT: AOT
};

module.exports = function(options) {
isProd = options.env === 'production';
return {

/**
* The entry point for the bundle
*
* See: http:https://webpack.github.io/docs/configuration.html#entry
*/
entry: {
'polyfills': helpers.root('src', 'polyfills.ts'),
'vendor': helpers.root('src', 'vendor.ts'),
'app': AOT ? helpers.root('src', 'main.aot.ts') : helpers.root('src', 'main.ts')
},

/**
* Options affecting the resolving of modules.
*
* See: http:https://webpack.github.io/docs/configuration.html#resolve
*/
resolve: {

/**
* An array of extensions that should be used to resolve modules.
*
* See: http:https://webpack.github.io/docs/configuration.html#resolve-extensions
*/
extensions: ['.ts', '.js', '.json'],

/**
* An array of directory names to be resolved to the current directory
*/
modules: [helpers.root('src'), helpers.root('node_modules')],
},

/**
* Options affecting the normal modules.
*
* See: http:https://webpack.github.io/docs/configuration.html#module
*/
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['es2015', {'modules': false}]
}
}
]
},
{
test: /\.ts$/,
loaders: [{
loader: 'awesome-typescript-loader',
options: {
configFileName: helpers.root('src', 'tsconfig.json'),
useCache: !isProd
}
},
'angular2-template-loader'
]
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'file-loader?name=assets/[name].[hash].[ext]'
},
{
test: /\.json$/,
loader: 'file-loader?name=assets/[name].[hash].json'
},
{
test: /\.(css|scss)$/,
exclude: /node_modules/,
use: [
'to-string-loader',
'style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
}
]
},
plugins: [
// Workaround for angular/angular#11580
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)@angular/,
helpers.root('./src'), // location of your src
{} // a map of your routes
),

new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills']
}),

new HtmlWebpackPlugin({
template: helpers.root('src', 'index.html')
}),

new WebpackShellPlugin({
onBuildStart: ['node ./config/dir-parse.js']
}),

new webpack.HotModuleReplacementPlugin(),

]
};
};
77 changes: 0 additions & 77 deletions config/webpack.common.js

This file was deleted.

Loading

0 comments on commit 779d2ed

Please sign in to comment.