I am currently using https://github.com/ng-bootstrap/ng-bootstrap in my angular2 application and using webpack2 to create all ts files.
I use only the Modal Component from NgbModule, but in the minified file I still see a link to NbgAccordian and other modules, which is not used in my application.
@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.15
I tried import { NgbModule, NgbModal, NgbModalOptions, ModalDismissReasons, NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';, but did not work as expected. This has something to do with tree tremors or the way Ngbmodule is written. Any options to remove unused modules from a vendor.jsfile
vendor.ts
import '@angular/core';
import '@angular/common';
import '@angular/forms';
import '@angular/http';
import '@angular/platform-browser';
import '@angular/platform-browser-dynamic';
import '@angular/router';
import 'rxjs';
import '@ng-bootstrap/ng-bootstrap';
import 'moment/moment';
import 'angular2-toaster/angular2-toaster';
import 'angular2-moment';
import 'ng2-tag-input';
import 'ng2-img-cropper';
webpack.prod.js
var webpack = require('webpack');
var webpackMerge = require('webpack-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var commonConfig = require('./webpack.common.js');
var CompressionPlugin = require("compression-webpack-plugin");
var helpers = require('./helpers');
var packageJson = require('../../package.json');
var version = packageJson.version;
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
var drop_console = true;
https:
module.exports = webpackMerge(commonConfig, {
devtool: "source-map",
plugins: [
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false,
options: {
htmlLoader: {
minimize: true,
removeAttributeQuotes: false,
caseSensitive: true,
customAttrSurround: [
[/#/, /(?:)/],
[/\*/, /(?:)/],
[/\[?\(?/, /(?:)/]
],
customAttrAssign: [/\)?\]?=/]
}
}
}),
new webpack.NoErrorsPlugin(),
new webpack.optimize.UglifyJsPlugin({
minimize: true,
sourceMap: true,
beautify: false,
comments: false,
mangle: {
toplevel : true,
screw_ie8: true,
keep_fnames: false
},
compress: {
screw_ie8: true,
dead_code : true,
unused : true,
warnings: false,
drop_console: drop_console
}
}),
new CompressionPlugin({
regExp: /\.css$|\.html$|\.js$|\.woff$|\.map$/,
algorithm: "gzip",
threshold: 2 * 1024,
minRatio: 0.8
}),
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(ENV)
}
})
]
});
----------------------------- Updates on 04/20/2017 -------- ------ -------
, root, ng bootstrap
app.modules.ts
import { NgbModalModule } from '@ng-bootstrap/ng-bootstrap/modal/modal.module';
import { NgbTooltipModule} from '@ng-bootstrap/ng-bootstrap/tooltip/tooltip.module';
import { NgbAlertModule } from '@ng-bootstrap/ng-bootstrap/alert/alert.module';
app.component.ts
import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap/modal/modal';
import { ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap/modal/modal-dismiss-reasons';
import { NgbActiveModal} from '@ng-bootstrap/ng-bootstrap/modal/modal-ref';
import { NgbTooltipConfig } from "@ng-bootstrap/ng-bootstrap/tooltip/tooltip-config";
vendor.ts
import { NgbModalModule, NgbModal, NgbModalOptions, ModalDismissReasons, NgbActiveModal, NgbTooltipModule, NgbTooltipConfig, NgbAlertModule } from '@ng-bootstrap/ng-bootstrap';
------ ------------
https://github.com/Andrey-Pavlov/angular2-webpack-starter/blob/d0a225851e6d63b03a21ad6b7a71552a941229ef/config/webpack.common.js#L220
