Skip to content

Commit

Permalink
chore(): add missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Apr 29, 2017
1 parent 6674f9a commit ff4940f
Show file tree
Hide file tree
Showing 14 changed files with 927 additions and 20 deletions.
23 changes: 3 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
dist/
dist
.DS_Store

**/*.js
**/*.js.map
**/*.d.ts

/docs

/aot
*.metadata.json
**/*.ngFactory.ts

/npm-debug.log

/node_modules
/typings

!gulpfile.js
/.idea
!rollup.config.js
node_modules
typings
611 changes: 611 additions & 0 deletions bundles/ngx-uploader.umd.js

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions src/specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Error.stackTraceLimit = Infinity;

require('core-js/es6');
require('core-js/es7/reflect');

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

require('rxjs/Rx');

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

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

let context = require.context('./app', true, /\.spec\.ts$/);
context.keys().map(context);
58 changes: 58 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const ngtools = require('@ngtools/webpack');
const webpackMerge = require('webpack-merge');
const commonPartial = require('./webpack/webpack.common');
const clientPartial = require('./webpack/webpack.client');
const serverPartial = require('./webpack/webpack.server');
const prodPartial = require('./webpack/webpack.prod');
const devPartial = require('./webpack/webpack.dev');
const { getAotPlugin } = require('./webpack/webpack.aot');
const { root } = require('./webpack/helpers');
const { getDevStylesConfig, getProdStylesConfig } = require('./webpack/webpack.style');
const portfinder = require('portfinder');

module.exports = function (options, webpackOptions) {
options = options || {};

if (options.aot) {
console.log(`Running build for ${options.client ? 'client' : 'server'} with AoT compilation...`)
}

const serverConfig = webpackMerge({}, commonPartial, serverPartial, {
entry: options.aot ? './src/main.server.aot.ts' : serverPartial.entry,
plugins: [
getAotPlugin('server', !!options.aot)
]
}, getProdStylesConfig());

let clientConfig = webpackMerge({}, commonPartial, clientPartial, {
plugins: [
getAotPlugin('client', !!options.aot)
]
}, options.dev ? getDevStylesConfig() : getProdStylesConfig());

if (webpackOptions.p) {
clientConfig = webpackMerge({}, clientConfig, prodPartial);
}

let config;

if (options.client) {
config = clientConfig;
} else if (options.server) {
config = serverConfig;
}

if (options.serve) {
if (!options.aot) {
config.module.rules.shift();
config = webpackMerge({}, config, devPartial);
}

return portfinder.getPortPromise().then(port => {
config.devServer.port = port;
return config;
});
} else {
return Promise.resolve(config);
}
}
24 changes: 24 additions & 0 deletions webpack.dist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const path = require('path');
const root = path.resolve(__dirname);
const webpack = require('webpack');
const ProvidePlugin = require('webpack/lib/ProvidePlugin');
const DefinePlugin = require('webpack/lib/DefinePlugin');
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');

module.exports = {
resolve: { extensions: ['.ts', '.js'] },
entry: path.join(root, 'ngx-uploader.ts'),
output: {
path: path.join(root, 'bundles'),
publicPath: '/',
filename: 'ngx-uploader.umd.js',
libraryTarget: 'umd',
library: 'ngx-uploader'
},
externals: [/^\@angular\//, /^rxjs\//],
module: {
rules: [
{ test: /\.ts$/, use: [ { loader: 'awesome-typescript-loader', options: { configFileName: 'src/tsconfig.browser.json' } }, { loader: 'angular2-template-loader' } ], exclude: [/\.aot\.ts$/] }
]
}
};
9 changes: 9 additions & 0 deletions webpack/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { resolve } = require('path');

function root(path) {
return resolve(__dirname, '..', path);
}

module.exports = {
root: root
};
18 changes: 18 additions & 0 deletions webpack/webpack.aot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { root } = require('./helpers');
const { AotPlugin } = require('@ngtools/webpack');

const tsconfigs = {
client: root('./src/tsconfig.browser.json'),
server: root('./src/tsconfig.server.json')
};

function getAotPlugin(platform, aot) {
return new AotPlugin({
tsConfigPath: tsconfigs[platform],
skipCodeGeneration: !aot
});
}

module.exports = {
getAotPlugin: getAotPlugin
};
18 changes: 18 additions & 0 deletions webpack/webpack.client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { root } = require('./helpers');
const { AotPlugin } = require('@ngtools/webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ScriptExtPlugin = require('script-ext-html-webpack-plugin');

module.exports = {
entry: root('./src/main.browser.ts'),
output: {
filename: 'app.bundle.js'
},
target: 'web',
plugins: [
new HtmlWebpackPlugin({
template: root('./src/index.html'),
output: root('dist')
})
]
};
35 changes: 35 additions & 0 deletions webpack/webpack.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const { root } = require('./helpers');
const copy = require('copy-webpack-plugin');

module.exports = {
resolve: {
extensions: ['.ts', '.js']
},
output: {
path: root('dist')
},
module: {
rules: [
{ test: /\.ts$/, loader: '@ngtools/webpack' },
{ test: /\.html$/, loader: 'raw-loader' },
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.(jp?g|png|gif)$/, loader: 'file-loader', options: { hash: 'sha512', digest: 'hex', name: 'images/[hash].[ext]' } },
{ test: /\.(eot|woff2?|svg|ttf|otf)([\?]?.*)$/, loader: 'file-loader', options: { hash: 'sha512', digest: 'hex', name: 'fonts/[hash].[ext]' } }
]
},
plugins: [
new copy([{ context: './public', from: '**/*' }])
],
devServer: {
historyApiFallback: true,
port: 8000,
open: true,
hot: false,
inline: true,
stats: { colors: true, chunks: false },
watchOptions: {
aggregateTimeout: 300,
poll: 1000
}
}
};
42 changes: 42 additions & 0 deletions webpack/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const { root } = require('./helpers');
const webpack = require('webpack');
const dll = require('webpack-dll-bundles-plugin').DllBundlesPlugin;
const assethtml = require('add-asset-html-webpack-plugin');

module.exports = {
output: {
path: root('dist'),
filename: '[name].bundle.js',
sourceMapFilename: '[name].bundle.map',
chunkFilename: '[id].chunk.js',
library: '[name]',
libraryTarget: 'var'
},
devtool: 'source-map',
plugins: [
new dll({
bundles: {
polyfills: [
'core-js',
{ name: 'zone.js', path: 'zone.js/dist/zone.js' },
{ name: 'zone.js', path: 'zone.js/dist/long-stack-trace-zone.js' }
],
vendor: [
'@angular/platform-browser', '@angular/platform-browser-dynamic', '@angular/core',
'@angular/common', '@angular/forms', '@angular/http', '@angular/router', 'rxjs'
]
},
dllDir: root('dist'),
webpackConfig: { devtool: 'cheap-module-source-map', plugins: [] }
}),
new assethtml([
{ filepath: root(`dist/${dll.resolveFile('polyfills')}`) },
{ filepath: root(`dist/${dll.resolveFile('vendor')}`) }
])
],
module: {
rules: [
{ test: /\.ts$/, use: [ { loader: 'ng-router-loader', options: { loader: 'async-import', genDir: './src/ngfactory', aot: false } }, { loader: 'awesome-typescript-loader', options: { configFileName: './src/tsconfig.browser.json' } }, { loader: 'angular2-template-loader' } ] }
]
}
}
9 changes: 9 additions & 0 deletions webpack/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { root } = require('./helpers');
const compression = require('compression-webpack-plugin');

module.exports = {
entry: root('src/main.browser.aot.ts'),
plugins: [
new compression({ asset: "[path].gz[query]", algorithm: "gzip", test: /\.js$|\.html$/, threshold: 10240, minRatio: 0.8 })
]
};
10 changes: 10 additions & 0 deletions webpack/webpack.server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { root } = require('./helpers');
const { AotPlugin } = require('@ngtools/webpack');

module.exports = {
entry: root('./src/main.server.ts'),
output: {
filename: 'server.js'
},
target: 'node'
};
36 changes: 36 additions & 0 deletions webpack/webpack.style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const { root } = require('./helpers');
const extract = require('extract-text-webpack-plugin');

function getDevStylesConfig() {
return {
module: {
rules: [
{ test: /\.css$/, use: ['style-loader', 'css-loader'], exclude: [root('src/app')] },
{ test: /\.css$/, use: ['to-string-loader', 'css-loader'], exclude: [root('src/styles')] },
{ test: /\.scss$|\.sass$/, use: ['style-loader', 'css-loader', 'sass-loader'], include: [root('src/styles') ] },
{ test: /\.scss$|\.sass$/, use: ['to-string-loader', 'css-loader', 'sass-loader'], exclude: [root('src/styles')] },
]
}
};
}

function getProdStylesConfig() {
return {
plugins: [
new extract('[name].css')
],
module: {
rules: [
{ test: /\.css$/, use: extract.extract({ fallback: 'style-loader', use: 'css-loader' }), include: [root('src/styles')] },
{ test: /\.css$/, use: ['to-string-loader', 'css-loader'], exclude: [root('src/styles')] },
{ test: /\.scss$|\.sass$/, loader: extract.extract({ fallback: 'style-loader', use: ['css-loader', 'sass-loader'] }), exclude: [root('src/app')] },
{ test: /\.scss$|\.sass$/, use: ['to-string-loader', 'css-loader', 'sass-loader'], exclude: [root('src/styles')] },
]
}
};
}

module.exports = {
getDevStylesConfig: getDevStylesConfig,
getProdStylesConfig: getProdStylesConfig
};
29 changes: 29 additions & 0 deletions webpack/webpack.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { root } = require('./helpers');

module.exports = function (options) {
return {
devtool: 'inline-source-map',
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{ enforce: 'pre', test: /\.js$/, loader: 'source-map-loader', exclude: [ root('node_modules/rxjs'), root('node_modules/@angular') ] },
{ test: /\.ts$/, use: [ { loader: 'awesome-typescript-loader', options: { configFileName: 'src/tsconfig.browser.json', module: 'commonjs' } }, { loader: 'angular2-template-loader' } ], exclude: [/\.aot\.ts$/] },
{ test: /\.json$/, loader: 'json-loader', exclude: [root('src/index.html')] },
{ test: /\.css$/, loader: ['to-string-loader', 'css-loader'], exclude: [root('src/index.html')] },
{ test: /\.scss$|\.sass$/, loader: ['raw-loader', 'sass-loader'], exclude: [root('src/index.html')] },
{ test: /\.html$/, loader: 'raw-loader', exclude: [root('src/index.html')] }
]
},
performance: { hints: false },
node: {
global: true,
process: false,
crypto: 'empty',
module: false,
clearImmediate: false,
setImmediate: false
}
};
}

0 comments on commit ff4940f

Please sign in to comment.