chore(dependencies): update dependencies, move to @types, some refactoring as per AngularClass/angular2-webpack-starter project

This commit is contained in:
nixa 2016-07-28 13:38:22 +03:00
parent 7d0ff2ef96
commit e7fca6d4ed
24 changed files with 505 additions and 295 deletions

View file

@ -1,20 +1,37 @@
const webpack = require('webpack');
const helpers = require('./helpers');
/*
* Webpack Plugins
*/
// problem with copy-webpack-plugin
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
var ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlElementsPlugin = require('./html-elements-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
/*
* Webpack Constants
*/
const METADATA = {
title: 'ng2-admin - Angular 2 Admin Template',
description: 'Free Angular 2 and Bootstrap 4 Admin Template',
baseUrl: '/'
};
/*
* Webpack configuration
*
* See: http://webpack.github.io/docs/configuration.html#cli
*/
module.exports = {
/*
* Static metadata for index.html
*
* See: (custom attribute)
*/
metadata: METADATA,
/*
@ -23,8 +40,10 @@ module.exports = {
* You can pass false to disable it.
*
* See: http://webpack.github.io/docs/configuration.html#cache
* cache: false,
*
*/
//cache: false,
/*
* The entry point for the bundle
* Our Angular.js app
*
@ -32,9 +51,9 @@ module.exports = {
*/
entry: {
'polyfills': './src/polyfills.ts',
'vendor': './src/vendor.ts',
'main': './src/main.browser.ts'
'polyfills': './src/polyfills.browser.ts',
'vendor': './src/vendor.browser.ts',
'main': './src/main.browser.ts'
},
@ -50,16 +69,21 @@ module.exports = {
*
* See: http://webpack.github.io/docs/configuration.html#resolve-extensions
*/
extensions: ['', '.ts', '.js', '.css', '.scss'],
extensions: ['', '.ts', '.js', '.css', '.scss', '.json'],
// Make sure root is src
root: helpers.root('src'),
// remove other default values
modulesDirectories: ['node_modules', 'bower_components']
modulesDirectories: ['node_modules'],
},
/*
* Options affecting the normal modules.
*
* See: http://webpack.github.io/docs/configuration.html#module
*/
module: {
/*
@ -74,7 +98,7 @@ module.exports = {
*
* See: https://github.com/wbuchwalter/tslint-loader
*/
// { test: /\.ts$/, loader: 'tslint-loader', exclude: [ helpers.root('node_modules') ] },
// { test: /\.ts$/, loader: 'tslint-loader', exclude: [ helpers.root('node_modules') ] },
/*
* Source map loader support for *.js files
@ -88,6 +112,8 @@ module.exports = {
exclude: [
// these packages have problems with their sourcemaps
helpers.root('node_modules/rxjs'),
helpers.root('node_modules/@angular'),
helpers.root('node_modules/@ngrx'),
helpers.root('node_modules/ng2-bootstrap'),
helpers.root('node_modules/ng2-branchy')
]
@ -95,6 +121,14 @@ module.exports = {
],
/*
* An array of automatically applied loaders.
*
* IMPORTANT: The loaders here are resolved relative to the resource which they are applied to.
* This means they are not resolved relative to the configuration file.
*
* See: http://webpack.github.io/docs/configuration.html#module-loaders
*/
loaders: [
/*
@ -119,14 +153,14 @@ module.exports = {
},
/*
* Raw loader support for *.css files
* to string and css loader support for *.css files
* Returns file content as string
*
* See: https://github.com/webpack/raw-loader
*/
{
test: /\.css$/,
loader: 'raw-loader'
// loaders: ['to-string-loader', 'css-loader']
loaders: ['raw-loader']
},
{
@ -208,7 +242,7 @@ module.exports = {
* See: https://github.com/webpack/docs/wiki/optimization#multi-page-app
*/
new webpack.optimize.CommonsChunkPlugin({
name: helpers.reverse(['polyfills', 'vendor'])
name: ['polyfills', 'vendor'].reverse()
}),
/*
@ -234,16 +268,39 @@ module.exports = {
*/
new HtmlWebpackPlugin({
template: 'src/index.html',
chunksSortMode: helpers.packageSort(['polyfills', 'vendor', 'main'])
chunksSortMode: 'dependency'
}),
// TODO: make sure this is a correct configuration
new webpack.ProvidePlugin({
jQuery: 'jquery',
$: 'jquery',
jquery: 'jquery',
'Tether': 'tether',
'window.Tether': 'tether'
}),
/*
* Plugin: HtmlHeadConfigPlugin
* Description: Generate html tags based on javascript maps.
*
* If a publicPath is set in the webpack output configuration, it will be automatically added to
* href attributes, you can disable that by adding a "=href": false property.
* You can also enable it to other attribute by settings "=attName": true.
*
* The configuration supplied is map between a location (key) and an element definition object (value)
* The location (key) is then exported to the template under then htmlElements property in webpack configuration.
*
* Example:
* Adding this plugin configuration
* new HtmlElementsPlugin({
* headTags: { ... }
* })
*
* Means we can use it in the template like this:
* <%= webpackConfig.htmlElements.headTags %>
*
* Dependencies: HtmlWebpackPlugin
*/
new HtmlElementsPlugin({
headTags: require('./head-config.common')
})
],