: .
: . .
, .
var path = require('path');
var webpack = require('webpack');
var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
var ProvidePlugin = webpack.ProvidePlugin;
module.exports = {
devtool: 'source-map',
debug: true,
cache: true,
entry: {
'vendor': './src/vendor.ts',
'app': './src/app/app.ts'
},
output: {
path: root('dist'),
filename: '[name].js',
sourceMapFilename: '[name].map',
chunkFilename: '[id].chunk.js',
pathinfo: true
},
resolve: {
extensions: ['', '.ts', '.js', '.json', '.css', '.html']
},
module: {
loaders: [
{
test: /\.ts$/,
loader: 'ts-loader',
query: {
'ignoreDiagnostics': [
2403,
2300,
2374,
2375
]
},
exclude: [/\.(spec|e2e)\.ts$/, /node_modules\/(?!(ng2-.+))/]
},
{test: /\.json$/, loader: 'json-loader'},
{test: /\.css$/, loaders: ['style', 'css']},
],
noParse: [/angular2-polyfills/]
},
plugins: [
new CommonsChunkPlugin({name: 'vendor', filename: 'vendor.js', minChunks: Infinity}),
new CommonsChunkPlugin({name: 'common', filename: 'common.js', minChunks: 2, chunks: ['app', 'vendor']}),
new ProvidePlugin({
$: "jquery",
jQuery: "jquery",
Cookies: "js-cookie"
})
],
tslint: {
emitErrors: true,
failOnHint: false
},
devServer: {
contentBase: 'src',
publicPath: '/__build__',
colors: true,
progress: true,
port: 3000,
displayCached: true,
displayErrorDetails: true,
inline: true
}
};
function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [__dirname].concat(args));
}
function rootNode(args) {
args = Array.prototype.slice.call(arguments, 0);
return root.apply(path, ['node_modules'].concat(args));
}
, . Angular 2/Bootstrap 4/OAuth2 Github project, Webpack.
Angular ( RxJS ) , vendor.ts, .
vendor.ts:
require('./css/bootstrap.css');
require('./css/main.css');
import 'angular2/bundles/angular2-polyfills';
import 'angular2/platform/browser';
import 'angular2/core';
import 'angular2/http';
import 'angular2/router';
index.html.
<script src="dist/common.js"></script>
<script src="dist/vendor.js"></script>
<script src="dist/app.js"></script>
, , , index.html .
, , . Github, .