Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
fix(webpack_config/): fix UglifyJS plugin, use rimraf
Browse files Browse the repository at this point in the history
fix(webpack_config/): fix UglifyJS plugin, use rimraf
  • Loading branch information
Metnew committed Oct 19, 2017
1 parent e2a1735 commit c720fc8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
31 changes: 14 additions & 17 deletions webpack_config/client/webpack.prod.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,14 @@ import OfflinePlugin from 'offline-plugin'
import UglifyJSPlugin from 'uglifyjs-webpack-plugin'
import {Plugin as ShakePlugin} from 'webpack-common-shake'
import OptimizeJsPlugin from 'optimize-js-plugin'
// import git from 'git-rev-sync'
// import _ from 'lodash'
// NOTE: WebpackShellPlugin allows you to run custom shell commands before and after build
// import WebpackShellPlugin from 'webpack-shell-plugin'
import {BundleAnalyzerPlugin} from 'webpack-bundle-analyzer'
import base from './webpack.base'
import config from '../config'
//
const {APP_LANGUAGE, ANALYZE_BUNDLE} = config

rimraf(`${config.distPath}/server/${APP_LANGUAGE}`, {}, () => {})
// NOTE: you can track versions with gitHash and store your build
// in dist folder with path like: /dist/client/<gitHash>/{yourFilesHere}
// const gitHash = git.short()
// Clean build dir
rimraf(`${config.distPath}/server`, {}, () => {})

// Do you want to use bundle analyzer?
if (config.ANALYZE_BUNDLE) {
Expand Down Expand Up @@ -79,15 +73,18 @@ base.plugins.push(
// NOTE: you can use BabiliPlugin as an alternative to UglifyJSPlugin
// new BabiliPlugin(),
new UglifyJSPlugin({
sourceMap: true,
compress: {
unused: true,
warnings: false,
dead_code: true,
drop_console: true
},
output: {
comments: false
uglifyOptions: {
sourceMap: true,
compress: {
warnings: false,
unused: true,
dead_code: true,
// This option removes console.log in production
drop_console: true
},
output: {
comments: false
}
}
}),
new OptimizeJsPlugin({
Expand Down
23 changes: 12 additions & 11 deletions webpack_config/server/webpack.prod.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@ const plugins = [
new webpack.optimize.ModuleConcatenationPlugin(),
new ShakePlugin(),
// NOTE: you can use BabiliPlugin as an alternative to UglifyJSPlugin
// new BabiliPlugin(),
new UglifyJSPlugin({
sourceMap: true,
compress: {
warnings: false,
unused: true,
dead_code: true
// This option removes console.log in production
// drop_console: true
},
output: {
comments: false
uglifyOptions: {
sourceMap: true,
compress: {
warnings: false,
unused: true,
dead_code: true,
// This option removes console.log in production
drop_console: true
},
output: {
comments: false
}
}
}),
new OptimizeJsPlugin({
Expand Down

0 comments on commit c720fc8

Please sign in to comment.