Skip to content

Refactor webpack config #358

Open
Open

Description

@anjmao

Current webpack config is very obscure and confusing. A lot of if(isTest), if(isProd)... and no single responsibility. I suggest to rewrite it using webpack-merge plugin and follow this guide https://webpack.js.org/guides/production/

This will allow to have files:

// all resolves and common plugins registered in common
webpack.common.js

// other builds uses webpack-merge to merge common and extend with custom
webpack.dev.js
webpack.prod.js
webpack.test.js

Example how I use it in my project for prod.

const path = require('path');
const merge = require('webpack-merge');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const common = require('./webpack.common.js');

module.exports = merge(common, {
  devtool: 'source-map',
  entry: './src/index.js',
  output: {
    filename: 'app.min.js',
    path: path.resolve(__dirname, 'dist')
  },
  plugins: [
    new UglifyJSPlugin({
      sourceMap: true
    })
  ]
});

Activity

  1. Foxandxss commented on Sep 15, 2017

    @Foxandxss
    Member

    I don't mind. I am just not working more on this project since the CLI is way way better.

  2. GaryB432 commented on Sep 15, 2017

    @GaryB432
    Contributor

    I feel again the impulse to say thanks for this great starter, @Foxandxss . I learned so much, for instance the webpack innards that I miss tweaking a little while I resist the temptation to eject my cli projects. Your work and creativity on this repo is much appreciated!

  3. Foxandxss commented on Sep 15, 2017

    @Foxandxss
    Member

    Thank you sir. I liked this project and I always wanted to continue it but this last 15 months I was part of the Angular team and I was more and more hooked with the CLI. It has always the latest latest and works really well.

  4. ollwenjones commented on Sep 15, 2017

    @ollwenjones
    Contributor

    was a huge help to us, too 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions