Skip to content

Commit

Permalink
(chore): new build
Browse files Browse the repository at this point in the history
  • Loading branch information
amcdnl committed Nov 29, 2016
1 parent ca7213a commit 3035802
Show file tree
Hide file tree
Showing 363 changed files with 39,477 additions and 6,353 deletions.
18 changes: 5 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
sudo: false
language: node_js

node_js:
- "6"
cache:
directories:
- node_modules
branches:
only:
- master
- 'node'

before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3

install:
- npm install
- npm i loader-utils
addons:
code_climate:
repo_token: 354a61ebebb73e09b1dbabff55de0a1350575913e0b3b20dfbb3426647addc96
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.check.workspaceVersion": false
}
4 changes: 2 additions & 2 deletions tasks/deploy-gh-page.js → config/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ var ghpages = require('gh-pages');
var dir = path.resolve(path.join(__dirname, '../', 'dist'));
ghpages.publish(dir, {
user: {
name: 'Marjan Georgiev',
email: 'marjan.georgiev@gmail.com'
name: 'Austin McDaniel',
email: 'amcdaniel2@gmail.com'
},
message: '(deploy): CI',
logger: function(message) {
Expand Down
8 changes: 4 additions & 4 deletions config/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ module.exports = function(config) {
singleRun: true,
frameworks: ['jasmine'],
exclude: [],
files: [
{ pattern: './config/spec-bundle.js', watched: false }
files: [
{ pattern: './config/spec-bundle.js', watched: false }
],
preprocessors: {
'./config/spec-bundle.js': ['coverage', 'webpack', 'sourcemap']
preprocessors: {
'./config/spec-bundle.js': ['coverage', 'webpack', 'sourcemap']
},
webpack: testWebpackConfig({ env: 'test' }),
webpackMiddleware: { stats: 'errors-only'},
Expand Down
10 changes: 9 additions & 1 deletion tasks/replace.js → config/replace.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var replace = require("replace");
const replace = require("replace");
const fs = require('fs-extra')

/**
* This replaces all the TypeScript references
Expand All @@ -12,3 +13,10 @@ replace({
recursive: true,
silent: false
});

/**
* ngc output pathing is totally wrong
*/
fs.copySync('./release/src', './release');
fs.removeSync('./release/node_modules')
fs.removeSync('./release/src')
39 changes: 23 additions & 16 deletions config/spec-bundle.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
/**
* Adapted from the angular2-webpack-starter kit.
*
* This file creates a bundle for testing, since tests are also
* written in ES6/Typescript. It's the entry point loaded by webpack.test.js
* @author: @AngularClass
*/

/*
* When testing with webpack and ES6, we have to do some extra
* things to get testing to work right. Because we are gonna write tests
* in ES6 too, we have to compile those as well. That's handled in
* karma.conf.js with the karma-webpack plugin. This is the entry
* file for webpack test. Just like webpack will create a bundle.js
* file for our client, when we run test, it will compile and bundle them
* all here! Crazy huh. So we need to do some setup
*/
Error.stackTraceLimit = Infinity;

require('core-js/es6');
Expand All @@ -15,32 +21,33 @@ require('ts-helpers');

require('zone.js/dist/zone');
require('zone.js/dist/long-stack-trace-zone');
require('zone.js/dist/proxy');
require('zone.js/dist/proxy'); // since zone.js 0.6.15
require('zone.js/dist/sync-test');
require('zone.js/dist/jasmine-patch');
require('zone.js/dist/jasmine-patch'); // put here since zone.js 0.6.14
require('zone.js/dist/async-test');
require('zone.js/dist/fake-async-test');

// RxJS
require('rxjs/Rx');

var testing = require('@angular/core/testing');
var browser = require('@angular/platform-browser-dynamic/testing');
const testing = require('@angular/core/testing');
const browser = require('@angular/platform-browser-dynamic/testing');

testing.TestBed.initTestEnvironment(
browser.BrowserDynamicTestingModule,
browser.platformBrowserDynamicTesting());
browser.BrowserDynamicTestingModule,
browser.platformBrowserDynamicTesting()
);

/*
* Ok, this is kinda crazy. We can use the the context method on
* Ok, this is kinda crazy. We can use the context method on
* require that webpack created in order to tell webpack
* what files we actually want to require or import.
* Below, context will be an function/object with file names as keys.
* using that regex we are saying look in ./src/app and ./test then find
* any file that ends with spec.js and get its path. By passing in true
* Below, context will be a function/object with file names as keys.
* Using that regex we are saying look in ../src then find
* any file that ends with spec.ts and get its path. By passing in true
* we say do this recursively
*/
var testContext = require.context('../src', true, /\.spec\.ts/);
const testContext = require.context('../src', true, /\.spec\.ts/);

/*
* get all the files, for each file, call the context function
Expand All @@ -52,4 +59,4 @@ function requireAll(requireContext) {
}

// requires and returns all modules that match
var modules = requireAll(testContext);
const modules = requireAll(testContext);
46 changes: 0 additions & 46 deletions config/testing-utils.ts

This file was deleted.

4 changes: 0 additions & 4 deletions config/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const { ENV, IS_PRODUCTION, APP_VERSION, dir } = require('./helpers');

module.exports = function(options = {}) {
Expand All @@ -14,9 +13,6 @@ module.exports = function(options = {}) {
dir('demo')
]
},
entry: {
'app': './demo/bootstrap.ts'
},
output: {
path: dir('dist'),
filename: '[name].js',
Expand Down
83 changes: 83 additions & 0 deletions config/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const WebpackNotifierPlugin = require('webpack-notifier');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const chalk = require('chalk');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;

const commonConfig = require('./webpack.common');
const { ENV, dir } = require('./helpers');

module.exports = function(options) {
return webpackMerge(commonConfig({ env: ENV }), {
devtool: 'cheap-module-source-map',
devServer: {
port: 9999,
hot: options.HMR,
stats: {
modules: false,
cached: false,
chunk: false
}
},
entry: {
'app': './demo/bootstrap.ts',
'libs': './demo/libs.ts'
},
module: {
exprContextCritical: false,
rules: [
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader',
exclude: /(node_modules)/
},
{
enforce: 'pre',
test: /\.ts$/,
loader: 'tslint-loader',
exclude: /(node_modules|release|dist)/
},
{
test: /\.ts$/,
loaders: [
'awesome-typescript-loader'
],
exclude: [/\.(spec|e2e|d)\.ts$/]
},
{
test: /\.scss$/,
loaders: [
'style-loader',
'css-loader?sourceMap',
'postcss-loader?sourceMap',
'sass-loader?sourceMap'
]
}
]
},
plugins: [
// new ForkCheckerPlugin(),
// new webpack.HotModuleReplacementPlugin()
new webpack.optimize.CommonsChunkPlugin({
name: ['libs'],
minChunks: Infinity
}),
new HtmlWebpackPlugin({
template: 'demo/index.html',
chunksSortMode: 'dependency',
title: 'ng2d3'
}),
new WebpackNotifierPlugin({
excludeWarnings: true
}),
new ProgressBarPlugin({
format: chalk.yellow.bold('Webpack Building...') +
' [:bar] ' + chalk.green.bold(':percent') + ' (:elapsed seconds)'
})
]
});

};
99 changes: 99 additions & 0 deletions config/webpack.package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const commonConfig = require('./webpack.common');
const { ENV, dir, APP_VERSION } = require('./helpers');
// const ngtools = require('@ngtools/webpack');

const banner =
`/**
* ng2d3 v${APP_VERSION} (https://github.com/swimlane/ng2d3)
* Copyright 2016
* Licensed under MIT
*/`;

module.exports = function(env) {
return webpackMerge(commonConfig({ env: ENV }), {
devtool: 'source-map',
module: {
exprContextCritical: false,
rules: [
{
test: /\.ts$/,
loaders: [
'awesome-typescript-loader'
],
exclude: [/\.(spec|e2e|d)\.ts$/]
},
{
test: /\.scss$/,
loaders: [
'style-loader',
'css-loader?sourceMap',
'postcss-loader?sourceMap',
'sass-loader?sourceMap'
]
}
]
},
entry: {
'index': './src/index.ts'
},
output: {
path: dir('release'),
libraryTarget: 'umd',
library: 'ng2d3',
umdNamedDefine: true
},
externals: {
'@angular/platform-browser-dynamic': '@angular/platform-browser-dynamic',
'@angular/platform-browser': '@angular/platform-browser',
'@angular/core': '@angular/core',
'@angular/common': '@angular/common',
'@angular/forms': '@angular/forms',
'core-js': 'core-js',
'core-js/es6': 'core-js/es6',
'core-js/es7/reflect': 'core-js/es7/reflect',
'd3-array': 'd3-array',
'd3-brush': 'd3-brush',
'd3-color': 'd3-color',
'd3-force': 'd3-force',
'd3-format': 'd3-format',
'd3-interpolate': 'd3-interpolate',
'd3-scale': 'd3-scale',
'd3-selection': 'd3-selection',
'd3-shape': 'd3-shape',
'd3-hierarchy': 'd3-hierarchy',
'rxjs': 'rxjs',
'rxjs/Rx': 'rxjs/Rx',
'rxjs/Subject': 'rxjs/Subject',
'rxjs/Subscription': 'rxjs/Subscription',
'rxjs/observable/PromiseObservable': 'rxjs/observable/PromiseObservable',
'rxjs/operator/toPromise': 'rxjs/operator/toPromise',
'rxjs/Observable': 'rxjs/Observable',
'zone.js/dist/zone': 'zone.js/dist/zone',
'moment': 'moment'
},
plugins: [
new webpack.BannerPlugin({
banner: banner,
raw: true,
entryOnly: true
}),
/*
new ngtools.AotPlugin({
tsConfigPath: 'tsconfig-aot.json',
baseDir: dir()
entryModule: dir('ng2d3.ts') + '#NG2D3Module'
}),
new CleanWebpackPlugin(['release'], {
root: dir(),
verbose: false,
dry: false
})
*/
]
});

};
Loading

0 comments on commit 3035802

Please sign in to comment.