Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): Adding support for custom uglify options in .angular-cli.json #5192

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions packages/@angular/cli/lib/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
"type": "array",
"description": "List of application assets.",
"items": {
"oneOf": [
{
"oneOf": [{
"type": "string"
},
{
Expand Down Expand Up @@ -118,8 +117,7 @@
"description": "Global styles to be included in the build.",
"type": "array",
"items": {
"oneOf": [
{
"oneOf": [{
"type": "string"
},
{
Expand Down Expand Up @@ -150,12 +148,16 @@
},
"additionalProperties": false
},
"uglifyOptions": {
"description": "Options to pass to the Uglify plugin",
"type": "object",
"additionalProperties": true
},
"scripts": {
"description": "Global scripts to be included in the build.",
"type": "array",
"items": {
"oneOf": [
{
"oneOf": [{
"type": "string"
},
{
Expand All @@ -174,7 +176,7 @@
},
"additionalProperties": false
},
"environmentSource":{
"environmentSource": {
"description": "Source file for environment config.",
"type": "string"
},
Expand Down Expand Up @@ -213,8 +215,7 @@
"properties": {
"files": {
"description": "File glob(s) to lint.",
"oneOf": [
{
"oneOf": [{
"type": "string"
},
{
Expand All @@ -237,8 +238,7 @@
},
"exclude": {
"description": "File glob(s) to ignore.",
"oneOf": [
{
"oneOf": [{
"type": "string"
},
{
Expand Down Expand Up @@ -475,7 +475,7 @@
},
"packageManager": {
"description": "Specify which package manager tool to use.",
"enum": [ "npm", "cnpm", "yarn", "default" ],
"enum": ["npm", "cnpm", "yarn", "default"],
"default": "default",
"type": "string"
},
Expand Down
13 changes: 9 additions & 4 deletions packages/@angular/cli/models/webpack-configs/production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ export const getProdConfig = function (wco: WebpackConfigOptions) {
const { projectRoot, buildOptions, appConfig } = wco;

let extraPlugins: any[] = [];
let entryPoints: {[key: string]: string[]} = {};
let entryPoints: { [key: string]: string[] } = {};
let appUglifyOptions = appConfig.uglifyOptions || {};
let baseUglifyOptions = {
mangle: { screw_ie8: true },
compress: { screw_ie8: true, warnings: buildOptions.verbose }
};

if (appConfig.serviceWorker) {
const nodeModules = path.resolve(projectRoot, 'node_modules');
Expand Down Expand Up @@ -65,7 +70,7 @@ export const getProdConfig = function (wco: WebpackConfigOptions) {

// Load the Webpack plugin for manifest generation and install it.
const AngularServiceWorkerPlugin = require('@angular/service-worker/build/webpack')
.AngularServiceWorkerPlugin;
.AngularServiceWorkerPlugin;
extraPlugins.push(new AngularServiceWorkerPlugin({
baseHref: buildOptions.baseHref || '/',
}));
Expand All @@ -87,8 +92,8 @@ export const getProdConfig = function (wco: WebpackConfigOptions) {
}),
new (<any>webpack).HashedModuleIdsPlugin(),
new webpack.optimize.UglifyJsPlugin(<any>{
mangle: { screw_ie8: true },
compress: { screw_ie8: true, warnings: buildOptions.verbose },
mangle: Object.assign(baseUglifyOptions.mangle, appUglifyOptions.mangle),
compress: Object.assign(baseUglifyOptions.compress, appUglifyOptions.compress),
sourceMap: buildOptions.sourcemap
})
].concat(extraPlugins)
Expand Down