Skip to content

Instantly share code, notes, and snippets.

@jamesmfriedman
Last active April 25, 2017 20:59
Show Gist options
  • Save jamesmfriedman/74cdc354560df65b7b8a19359f4ba8d8 to your computer and use it in GitHub Desktop.
Save jamesmfriedman/74cdc354560df65b7b8a19359f4ba8d8 to your computer and use it in GitHub Desktop.

Revisions

  1. jamesmfriedman revised this gist Apr 25, 2017. No changes.
  2. jamesmfriedman revised this gist Apr 25, 2017. 1 changed file with 17 additions and 17 deletions.
    34 changes: 17 additions & 17 deletions webpack.config.js
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,9 @@ const webpack = require('webpack');
    const HtmlWebpackPlugin = require('html-webpack-plugin');

    module.exports = function(env) {
    // merge together build and environment variables
    // to be made available in process.env
    const processEnv = Object.assign({}, env, require('./env.' + env.NODE_ENV));
    // merge together build and environment variables
    // to be made available in process.env
    const processEnv = Object.assign({}, env, require('./env.' + env.NODE_ENV));

    // define our entries
    const entries = {
    @@ -18,22 +18,22 @@ module.exports = function(env) {
    }

    return {
    entry: entries
    output: {...},
    module: {...},
    devServer: {...}
    plugins: [
    entry: entries
    output: {...},
    module: {...},
    devServer: {...}
    plugins: [
    // This will generate an index.html file for us and emit it into our
    // output director
    new HtmlWebpackPlugin({
    filename: 'index.html',
    template: 'src/index.ejs' //point our template to a .ejs file
    }),
    new HtmlWebpackPlugin({
    filename: 'index.html',
    template: 'src/index.ejs' //point our template to a .ejs file
    }),

    // we need process.env available in our template
    new webpack.DefinePlugin({
    'process.env': JSON.stringify(processEnv)
    }),
    ]
    }
    new webpack.DefinePlugin({
    'process.env': JSON.stringify(processEnv)
    }),
    ]
    }
    };
  3. jamesmfriedman revised this gist Apr 25, 2017. No changes.
  4. jamesmfriedman revised this gist Apr 25, 2017. No changes.
  5. jamesmfriedman revised this gist Apr 25, 2017. No changes.
  6. jamesmfriedman created this gist Apr 25, 2017.
    39 changes: 39 additions & 0 deletions webpack.config.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    const webpack = require('webpack');
    const HtmlWebpackPlugin = require('html-webpack-plugin');

    module.exports = function(env) {
    // merge together build and environment variables
    // to be made available in process.env
    const processEnv = Object.assign({}, env, require('./env.' + env.NODE_ENV));

    // define our entries
    const entries = {
    'polyfills': ['./src/polyfills.ts'],
    'app': ['./src/main.ts']
    };

    // add in the styles js file if we're doing dev
    if (~process.env.BUILD_ENV.search('dev')) {
    entries['styles'] = ['./src/styles.js'];
    }

    return {
    entry: entries
    output: {...},
    module: {...},
    devServer: {...}
    plugins: [
    // This will generate an index.html file for us and emit it into our
    // output director
    new HtmlWebpackPlugin({
    filename: 'index.html',
    template: 'src/index.ejs' //point our template to a .ejs file
    }),

    // we need process.env available in our template
    new webpack.DefinePlugin({
    'process.env': JSON.stringify(processEnv)
    }),
    ]
    }
    };