Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const NODE_ENV = process.env.NODE_ENV || 'development';
- const path = require('path');
- const webpack = require('webpack');
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- const CopyWebpackPlugin = require('copy-webpack-plugin');
- const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
- const ExtractTextPlugin = require('extract-text-webpack-plugin');
- let config = {
- entry: {
- app: ["babel-polyfill", 'whatwg-fetch', './src/client.js'],
- },
- output: {
- filename: 'js/[name].js',
- publicPath: '/',
- path: '/var/www/web',
- library: '[name]'
- },
- devtool: 'source-map',
- module: {
- loaders: [
- {
- test: /\.jsx?$/,
- use: {
- loader: 'babel-loader',
- options: {
- presets: ['env', 'es2015', 'stage-2', 'react-app'],
- babelrc: false
- }
- }
- },
- {test: /\.(png|jpg|gif|svg)$/, loader: 'file-loader?name=img/[name]-[sha512:hash:base64:7].[ext]'},
- {
- test: /\.(ttf|otf|eot|woff(2)?)(\?[a-z0-9]+)?$/,
- loader: 'file-loader?name=fonts/[name]-[sha512:hash:base64:7].[ext]'
- },
- {
- test: /\.css$/,
- use: ExtractTextPlugin.extract({
- fallback: "style-loader",
- use: "css-loader"
- })
- }
- ]
- },
- plugins: [
- new webpack.EnvironmentPlugin(['NODE_ENV']),
- new webpack.optimize.CommonsChunkPlugin({
- name: "app",
- minChunks: function (module, count) {
- return (!module.context || !module.context.includes("node_modules")) && count >= 2;
- }
- }),
- new webpack.optimize.CommonsChunkPlugin({
- name: "vendor",
- chunks: ['app'],
- minChunks: function(module){
- return module.context && module.context.includes("node_modules");
- }
- }),
- new ExtractTextPlugin('css/styles.css'),
- new CopyWebpackPlugin([
- {from: './src/assets', to: 'public'},
- {from: './src/assets/favicon', to: ''}
- ]),
- new HtmlWebpackPlugin({
- title: 'Bitrent',
- template: 'src/index.ejs',
- hash: true,
- cache: false
- })
- ]
- };
- if (NODE_ENV === 'production') {
- config.plugins.push(
- new UglifyJsPlugin({})
- );
- config.devtool = false;
- }
- module.exports = config;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement