preboot/angular-webpack

Refactor webpack config

anjmao opened this issue · 4 comments

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
    })
  ]
});

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

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!

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.

was a huge help to us, too 👍