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

Updated to work with current webpack (4.x) and UglifyJS #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
37 changes: 22 additions & 15 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
var path = require("path");
var webpack = require("webpack");

const UglifyJsPlugin = require("uglifyjs-webpack-plugin");

var PATHS = {
entryPoint: path.resolve(__dirname, 'src/index.ts'),
bundles: path.resolve(__dirname, '_bundles'),
}

var config = {
mode: 'production', // suppress warning
// These are the entry point of our library. We tell webpack to use
// the name we assign later, when creating the bundle. We also use
// the name to filter the second entry point for applying code
Expand All @@ -31,36 +34,40 @@ var config = {
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
// Activate source maps for the bundles in order to preserve the original
// source when the user debugs the application
devtool: 'source-map',
plugins: [
// Apply minification only on the second bundle by
// using a RegEx on the name, which must end with `.min.js`
// NB: Remember to activate sourceMaps in UglifyJsPlugin
// since they are disabled by default!
new webpack.optimize.UglifyJsPlugin({
minimize: true,
sourceMap: true,
include: /\.min\.js$/,
})
],
module: {
// Webpack doesn't understand TypeScript files and a loader is needed.
// `node_modules` folder is excluded in order to prevent problems with
// the library dependencies, as well as `__tests__` folders that
// contain the tests for the library
loaders: [{
rules: [{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader',
exclude: /node_modules/,
query: {
// we don't want any declaration file in the bundles
// folder since it wouldn't be of any use ans the source
// folder since it wouldn't be of any use and the source
// map already include everything for debugging
declaration: false,
}
}]
},
optimization: {
minimizer: [
// Apply minification only on the second bundle by
// using a RegEx on the name, which must end with `.min.js`
// NB: Remember to activate sourceMaps in UglifyJsPlugin
// since they are disabled by default!
new UglifyJsPlugin({
include: /\.min\.js$/,
cache: true,
parallel: true,
uglifyOptions: {
minimize: true
},
sourceMap: true
})
]
}
}

Expand Down