Skip to content

Instantly share code, notes, and snippets.

@VoloshchenkoAl
Last active April 13, 2017 13:08
Show Gist options
  • Save VoloshchenkoAl/79dbbe6b731a728c168f0955ec050c8a to your computer and use it in GitHub Desktop.
Save VoloshchenkoAl/79dbbe6b731a728c168f0955ec050c8a to your computer and use it in GitHub Desktop.
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const path = require('path');
const bundleFolder = './entry/';
const fs = require('fs');
const testFiles = /\.js$/;
const arrayFiles = fs.readdirSync(bundleFolder);
const AssetsPlugin = require('assets-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const objEntry = arrayFiles.reduce(function (result, item) {
if (testFiles.test(item)) {
var objName = item.slice(0, -3);
result[objName] = bundleFolder + item;
}
return result;
}, {});
module.exports = {
entry: objEntry,
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build')
},
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader?url=false&minimize=true'
})
}
]
},
plugins: [
new ExtractTextPlugin("[name]-[chunkhash].css"),
new UglifyJSPlugin(),
new AssetsPlugin({ filename: 'assets.json' })
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment