Skip to content

Commit

Permalink
minify when building for production
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Nov 5, 2017
1 parent d547255 commit 3d0b7d7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 36 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"examples/"
],
"scripts": {
"build": "webpack -p",
"prepublishOnly": "npm run build",
"buildProduction": "webpack --env production",
"prepublishOnly": "npm run buildProduction",
"lint": "tslint -c tslint.json 'src/**/*.ts'"
},
"dependencies": {
Expand Down
74 changes: 40 additions & 34 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
const path = require('path')
const MinifyPlugin = require("babel-minify-webpack-plugin");

module.exports = {
entry: './src/index.ts',
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
modules: true,
module.exports = (env) => {
let plugins = []
if (env === 'production')
plugins = [new MinifyPlugin()];

return {
entry: './src/index.ts',
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
modules: true,
}
}
}
]
}
]
},
resolve: {
extensions: [ ".ts", ".js" ]
},
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'dist'),
libraryTarget: "umd"
},
plugins: [
]
]
}
]
},
resolve: {
extensions: [ ".ts", ".js" ]
},
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'dist'),
libraryTarget: "umd"
},
plugins
}
};

0 comments on commit 3d0b7d7

Please sign in to comment.