const os = require('os'); const path = require('path'); const webpack = require('webpack'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const HappyPack = require('happypack'); const threadPoolCount = os.cpus().length; const happyThreadPool = HappyPack.ThreadPool({ size: threadPoolCount }); const source = __dirname; const destination = __dirname; const VendorDll = new webpack.DllPlugin({ name: '[name]', path: path.resolve(destination, '[name]-manifest.json'), }); const ExtractCSS = new ExtractTextPlugin({ filename: '[name].bundle.css', allChunks: true, }); module.exports = [ { entry: { vendor: [ 'babel-polyfill', 'underscore', 'vue', 'normalize.css', ], }, output: { filename: '[name].bundle.js', library: '[name]', path: destination, publicPath: '/', }, module: { rules: [ { test: /\.css$/, loader: ExtractCSS.extract({ fallback: 'style-loader', use: ['happypack/loader?id=css'], use: ['css-loader'], }), }, { test: /\.js$/, loaders: ['happypack/loader?id=js'], }, ], }, plugins: [ new HappyPack({ id: 'css', threadPool: happyThreadPool, loaders: [ { loader: 'css-loader', } ], }), new HappyPack({ id: 'js', threadPool: happyThreadPool, loaders: [ { loader: 'babel-loader', }, ], }), VendorDll, ExtractCSS, ], }, ];