Last active
April 13, 2017 13:08
-
-
Save VoloshchenkoAl/79dbbe6b731a728c168f0955ec050c8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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