iliakan/webpack-screencast

01-intro does not work

ryaa opened this issue · 1 comments

ryaa commented

Followed the instructions and running webpack command for 01-intro gives and error. This could be that it is not webpack 2 compatible or smth...

ryaa commented

Had to install node modules

npm i babel-loader babel-core babel-preset-es2015 babel-plugin-transform-es2015-modules-commonjs

and make some changes to webpack.config.js to make it to work (below is the config with my changes)

'use strict';

const NODE_ENV = process.env.NODE_ENV || 'development';
const webpack = require('webpack');

module.exports = {
  entry:  "./home",
  output: {
    filename: "build.js",
    library:  "home"
  },

  watch: NODE_ENV == 'development',

  watchOptions: {
    aggregateTimeout: 100
  },

  devtool: NODE_ENV == 'development' ? "cheap-inline-module-source-map" : null,

  plugins: [
    new webpack.DefinePlugin({
      NODE_ENV: JSON.stringify(NODE_ENV),
      LANG:     JSON.stringify('ru')
    })
  ],

  resolve: {
    modules: ['node_modules'],
    extensions:         ['.js']
  },

  resolveLoader: {
    modules: ['node_modules'],
    extensions:         ['.js']
  },


  module: {

    loaders: [{
      test:   /\.js$/,
      loader: 'babel-loader?presets[]=es2015'
    }]

  }

};


if (NODE_ENV == 'production') {
  module.exports.plugins.push(
      new webpack.optimize.UglifyJsPlugin({
        compress: {
          // don't show unreachable variables etc
          warnings:     false,
          drop_console: true,
          unsafe:       true
        }
      })
  );
}