webpack-auto-inject-version/demo/webpack.conf.js

86 lines
2.2 KiB
JavaScript
Raw Normal View History

const path = require('path');
2018-03-15 22:07:22 +11:00
const CompressionPlugin = require('compression-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin')
2018-03-15 22:07:22 +11:00
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 )
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 = {
watch: true,
2017-04-11 09:11:09 +10:00
entry: {
index: ['./src/main.js'],
2017-04-11 09:11:09 +10:00
},
resolve: {
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]',
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: [
path.resolve('src'),
],
2017-04-11 09:11:09 +10:00
},
{
test: /\.json$/,
loader: 'json-loader',
2017-04-11 09:11:09 +10:00
},
{
test: /\.txt$/,
loader: 'raw-loader',
2017-04-11 09:11:09 +10:00
},
{
test: /\.html$/,
loader: 'raw-loader!html-minify-loader',
},
],
2017-04-11 09:11:09 +10:00
},
plugins: [
new CleanWebpackPlugin(path.resolve(process.cwd(), 'dist')),
2017-04-11 09:11:09 +10:00
new WebpackAutoInject({
components: {
InjectAsComment: false,
},
componentsOptions: {
InjectByTag: {
dateFormat: 'h:MM:ss',
},
},
// components: {
// AutoIncreaseVersion: true,
// InjectAsComment: true,
// InjectByTag: true,
// },
// componentsOptions: {
// AutoIncreaseVersion: {
// runInWatchMode: false, // it will increase version with every single build!
// },
// InjectAsComment: {
// tag: 'Version: {version}, {date}',
// },
// InjectByTag: {
// fileRegex: /\.+/,
// dateFormat: 'h:MM:ss',
// },
// },
}),
// new CompressionPlugin({
// algorithm: 'gzip',
// }),
// new UglifyJsPlugin(),
],
2017-04-11 09:11:09 +10:00
};