2018-03-15 18:55:41 +11:00
|
|
|
const path = require('path');
|
|
|
|
|
2018-03-15 22:07:22 +11:00
|
|
|
const CompressionPlugin = require('compression-webpack-plugin');
|
|
|
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
|
|
|
|
2017-04-11 09:15:51 +10:00
|
|
|
// Require WebpackAutoInject from npm installed modules ( preferred )
|
2017-04-13 08:40:22 +10:00
|
|
|
// var WebpackAutoInject = require('webpack-auto-inject-version');
|
2017-04-11 09:11:09 +10:00
|
|
|
// Require WebpackAutoInject from dist - dev purpose only ( do not use the below line )
|
2018-03-15 18:55:41 +11:00
|
|
|
const WebpackAutoInject = require('../dist/WebpackAutoInjectVersion');
|
2017-04-11 09:11:09 +10:00
|
|
|
|
2018-03-15 22:07:22 +11:00
|
|
|
|
2017-04-11 09:11:09 +10:00
|
|
|
module.exports = {
|
2017-08-25 23:00:19 +10:00
|
|
|
watch: true,
|
2017-04-11 09:11:09 +10:00
|
|
|
entry: {
|
2018-03-15 18:55:41 +11:00
|
|
|
index: ['./src/main.js'],
|
2017-04-11 09:11:09 +10:00
|
|
|
},
|
|
|
|
resolve: {
|
2018-03-15 18:55:41 +11:00
|
|
|
extensions: ['.js', '.html'],
|
2017-04-11 09:11:09 +10:00
|
|
|
},
|
|
|
|
output: {
|
2018-03-15 22:07:22 +11:00
|
|
|
// filename: '[name]-bundle.js',
|
|
|
|
// path: path.resolve(process.cwd(), 'dist'),
|
|
|
|
// publicPath: '/', // Public path to 'dist' scope in production
|
|
|
|
filename: 'js/main.js?[chunkhash]',
|
2018-03-15 18:55:41 +11:00
|
|
|
path: path.resolve(process.cwd(), 'dist'),
|
2018-03-15 22:07:22 +11:00
|
|
|
chunkFilename: 'js/main.js?[chunkhash]',
|
2017-04-11 09:11:09 +10:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
loaders: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
include: [
|
2018-03-15 18:55:41 +11:00
|
|
|
path.resolve('src'),
|
|
|
|
],
|
2017-04-11 09:11:09 +10:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.json$/,
|
2018-03-15 18:55:41 +11:00
|
|
|
loader: 'json-loader',
|
2017-04-11 09:11:09 +10:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.txt$/,
|
2018-03-15 18:55:41 +11:00
|
|
|
loader: 'raw-loader',
|
2017-04-11 09:11:09 +10:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.html$/,
|
2018-03-15 18:55:41 +11:00
|
|
|
loader: 'raw-loader!html-minify-loader',
|
|
|
|
},
|
|
|
|
],
|
2017-04-11 09:11:09 +10:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new WebpackAutoInject({
|
|
|
|
components: {
|
2018-03-15 19:00:19 +11:00
|
|
|
AutoIncreaseVersion: true,
|
|
|
|
InjectAsComment: true,
|
2018-03-15 18:55:41 +11:00
|
|
|
InjectByTag: true,
|
2017-08-25 23:00:19 +10:00
|
|
|
},
|
|
|
|
componentsOptions: {
|
|
|
|
AutoIncreaseVersion: {
|
2018-03-15 18:55:41 +11:00
|
|
|
runInWatchMode: false, // it will increase version with every single build!
|
2017-08-25 23:00:19 +10:00
|
|
|
},
|
|
|
|
InjectAsComment: {
|
2018-03-15 18:55:41 +11:00
|
|
|
tag: 'Version: {version}, {date}',
|
2017-08-25 23:00:19 +10:00
|
|
|
},
|
|
|
|
InjectByTag: {
|
2018-03-15 18:55:41 +11:00
|
|
|
fileRegex: /\.+/,
|
|
|
|
dateFormat: 'h:MM:ss',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
2018-03-15 22:07:22 +11:00
|
|
|
new CompressionPlugin({
|
|
|
|
algorithm: 'gzip',
|
|
|
|
}),
|
|
|
|
new UglifyJsPlugin(),
|
2018-03-15 18:55:41 +11:00
|
|
|
],
|
2017-04-11 09:11:09 +10:00
|
|
|
};
|