1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-04-28 04:43:15 +02:00
TableFilter/webpack.config.js

88 lines
2.7 KiB
JavaScript
Raw Normal View History

2018-03-16 06:21:41 +01:00
const webpack = require('webpack');
const path = require('path');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
2018-03-16 06:21:41 +01:00
const StringReplacePlugin = require('string-replace-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
2018-03-16 06:21:41 +01:00
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
module.exports = {
2018-02-28 11:53:57 +01:00
mode: 'production',
2015-06-06 14:22:13 +02:00
cache: true,
2015-07-04 16:34:07 +02:00
entry: {
'main': path.join(__dirname, '/src/tablefilter.js')
},
2015-06-06 14:22:13 +02:00
output: {
path: path.join(__dirname, '/dist/tablefilter'),
filename: 'tablefilter.js',
2016-12-24 13:35:26 +01:00
chunkFilename: 'tf-[name]-[chunkhash].js',
2015-06-06 14:22:13 +02:00
libraryTarget: 'umd'
},
2015-06-06 14:22:13 +02:00
resolve: {
2017-01-29 12:50:12 +01:00
extensions: ['.js'],
2015-06-06 14:22:13 +02:00
alias: {
sortabletable: '../../../libs/sortabletable.js'
}
},
module: {
2017-01-29 12:50:12 +01:00
rules: [
{
test: path.join(__dirname, 'src'),
exclude: /tablefilter\/node_modules/,
2017-02-03 07:04:07 +01:00
options: {
2015-12-25 15:33:04 +01:00
compact: false,
presets: ['@babel/env']
},
loader: 'babel-loader'
2017-02-03 07:04:07 +01:00
}, {
test: path.join(__dirname, 'src'),
loader: StringReplacePlugin.replace({
replacements: [{
pattern: /{VERSION}/ig,
replacement: function (/*match, p1, offset, string*/) {
return pkg.version;
}
2015-09-04 13:57:27 +02:00
},{
pattern: /{AUTHOR}/ig,
replacement: function () {
return pkg.author.name;
}
}]
})
2018-03-18 03:20:44 +01:00
}
]
},
2017-02-03 07:04:07 +01:00
devtool: 'source-map',
2018-02-28 11:53:57 +01:00
optimization: {
minimizer: [
new UglifyJsPlugin({
2018-06-15 12:47:30 +02:00
sourceMap: true,
uglifyOptions: {
beautify: false,
2019-06-06 02:33:43 +02:00
warnings: false,
comments: false,
keep_fnames: true
}
})
]
2018-02-28 11:53:57 +01:00
},
2017-02-03 07:04:07 +01:00
plugins: [
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [path.join(process.cwd(), 'dist')]
}),
2017-02-03 07:04:07 +01:00
new webpack.optimize.AggressiveMergingPlugin(),
new StringReplacePlugin(),
2018-02-28 11:53:57 +01:00
new webpack.optimize.MinChunkSizePlugin({
minChunkSize: 10000
2017-02-03 07:04:07 +01:00
}),
new webpack.BannerPlugin({
banner: '/** \n' +
' *\t '+pkg.name+' v'+pkg.version+' by '+pkg.author.name+'\n' +
' *\t build date: '+ new Date().toISOString() +' \n' +
' *\t MIT License \n' +
' */ \n',
raw: true
})
]
};