chore(build): ng2 style guide applied,

- build process updated
- systemjs bundler added

BREAKING CHANGES:
- directives and selectors renamed to ng2FileSelect and ng2FileDrop
This commit is contained in:
Dmitriy Shekhovtsov
2016-05-11 18:40:47 +03:00
parent 13c5c35864
commit aee69d8b80
30 changed files with 743 additions and 740 deletions

View File

@@ -1,35 +1,35 @@
var path = require('path');
var marked = require('marked');
var webpack = require('webpack');
/* eslint global-require: 0 */
'use strict';
var Clean = require('clean-webpack-plugin');
var CompressionPlugin = require('compression-webpack-plugin');
const path = require('path');
const marked = require('marked');
const webpack = require('webpack');
const reqPrism = require('prismjs');
const CompressionPlugin = require('compression-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// marked renderer hack
marked.Renderer.prototype.code = function (code, lang) {
var out = this.options.highlight(code, lang);
marked.Renderer.prototype.code = function renderCode(code, lang) {
const out = this.options.highlight(code, lang);
const classMap = this.options.langPrefix + lang;
if (!lang) {
return '<pre><code>' + out + '\n</code></pre>';
return `<pre><code>${out}\n</code></pre>`;
}
var classMap = this.options.langPrefix + lang;
return '<pre class="' + classMap + '"><code class="' + classMap + '">' + out + '\n</code></pre>\n';
return `<pre class="${classMap}"><code class="${classMap}">${out}\n</code></pre>\n`;
};
/*eslint no-process-env:0, camelcase:0*/
var isProduction = (process.env.NODE_ENV || 'development') === 'production';
const isProduction = (process.env.NODE_ENV || 'development') === 'production';
const devtool = process.env.NODE_ENV === 'test' ? 'inline-source-map' : 'source-map';
const dest = 'demo-build';
const absDest = root(dest);
var src = 'demo';
//var absSrc = path.join(__dirname, src);
var dest = '/build';
var absDest = path.join(__dirname, dest);
var config = {
const config = {
// isProduction ? 'source-map' : 'evale',
devtool: 'source-map',
debug: true,
cache: true,
devtool,
debug: false,
verbose: true,
displayErrorDetails: true,
@@ -40,9 +40,9 @@ var config = {
},
resolve: {
cache: false,
root: __dirname,
extensions: ['', '.ts', '.js', '.json'],
alias: {}
extensions: ['', '.ts', '.js', '.json']
},
entry: {
@@ -55,8 +55,8 @@ var config = {
'@angular/common',
'@angular/core'
],
'angular2-file-upload': ['ng2-file-upload'],
'angular2-file-upload-demo': 'demo'
'angular2-bootstrap': ['ng2-file-upload'],
'angular2-bootstrap-demo': 'demo'
},
output: {
@@ -71,23 +71,20 @@ var config = {
inline: true,
colors: true,
historyApiFallback: true,
proxy: {
'*/api/*': 'http://localhost:3000/'
},
contentBase: src,
publicPath: dest
contentBase: dest,
//publicPath: dest,
outputPath: dest,
watchOptions: {aggregateTimeout: 300, poll: 1000}
},
markdownLoader: {
langPrefix: 'language-',
highlight: function (code, lang) {
var language = !lang || lang === 'html' ? 'markup' : lang;
if (!global.Prism) {
global.Prism = require('prismjs');
}
var Prism = global.Prism;
highlight(code, lang) {
const language = !lang || lang === 'html' ? 'markup' : lang;
const Prism = global.Prism || reqPrism;
if (!Prism.languages[language]) {
require('prismjs/components/prism-' + language + '.js');
require(`prismjs/components/prism-${language}.js`);
}
return Prism.highlight(code, Prism.languages[language]);
}
@@ -96,77 +93,65 @@ var config = {
loaders: [
// support markdown
{test: /\.md$/, loader: 'html?minimize=false!markdown'},
// Support for *.json files.
{test: /\.json$/, loader: 'json'},
// Support for CSS as raw text
{test: /\.css$/, loader: 'raw'},
// support for .html as raw text
{test: /\.html$/, loader: 'raw'},
// Support for .ts files.
{
test: /\.ts$/,
loader: 'ts',
query: {
ignoreDiagnostics: [
6053,
// TS2305 -> Module 'ng' has no exported member
2305,
// TS2307 -> Cannot find external module
2307,
// TS2300 -> Duplicate identifier
2300,
// TS2309 -> An export assignment cannot be used in a module with other exported elements.
2309
]
compilerOptions: {
removeComments: true,
noEmitHelpers: false
}
},
exclude: [
/\.min\.js$/,
/\.spec\.ts$/,
/\.e2e\.ts$/,
/web_modules/,
/test/
]
exclude: [/\.(spec|e2e)\.ts$/]
}
],
noParse: [
/rtts_assert\/src\/rtts_assert/,
/reflect-metadata/
/reflect-metadata/,
/zone\.js\/dist\/zone-microtask/
]
},
plugins: [
new Clean(['build']),
//new Clean([dest]),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(true),
new webpack.optimize.CommonsChunkPlugin({
name: 'angular2',
minChunks: Infinity,
filename: 'angular2.js'
}),
new webpack.optimize.DedupePlugin({
__isProduction: isProduction
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin()
// static assets
new CopyWebpackPlugin([{from: 'demo/favicon.ico', to: 'favicon.ico'}]),
new CopyWebpackPlugin([{from: 'demo/assets', to: 'assets'}]),
// generating html
new HtmlWebpackPlugin({template: 'demo/index.html'})
],
pushPlugins: function () {
pushPlugins() {
if (!isProduction) {
return;
}
this.plugins.push.apply(this.plugins, [
const plugins = [
//production only
new webpack.optimize.UglifyJsPlugin({
beautify: false,
mangle: false,
comments: false,
compress: {
warnings: false,
drop_debugger: false
},
output: {
comments: false
},
beautify: false
screw_ie8: true
//warnings: false,
//drop_debugger: false
}
//verbose: true,
//beautify: false,
//quote_style: 3
}),
new CompressionPlugin({
asset: '{file}.gz',
@@ -175,10 +160,19 @@ var config = {
threshold: 10240,
minRatio: 0.8
})
]);
];
this
.plugins
.push
.apply(plugins);
}
};
config.pushPlugins();
module.exports = config;
function root(partialPath) {
return path.join(__dirname, partialPath);
}