<|start_filename|>packages/webpack-preset-babel-stage-3/package.json<|end_filename|>
{
  "name": "webpack-preset-babel-stage-3",
  "version": "0.2.0",
  "description": "stage-3 Babel preset for webpack-preset-babel",
  "author": "<NAME> <<EMAIL>>",
  "homepage": "https://github.com/webpack-preset/webpack-preset/tree/master/packages/webpack-preset-babel-stage-3",
  "license": "MIT",
  "repository": "https://github.com/webpack-preset/webpack-preset/tree/master/packages/webpack-preset-babel-stage-3",
  "main": "index.js",
  "dependencies": {
    "babel-preset-stage-3": "^6.3.13"
  }
}


<|start_filename|>src/config/index.js<|end_filename|>
const loadPackageJSON = require('./json')
const findPresets = require('./presets')

const baseConfig = require('./base')

module.exports = function config() {
  const packageJSON = loadPackageJSON()
  const presets = findPresets(Object.assign(
    {},
    packageJSON.dependencies,
    packageJSON.devDependencies
  ))

  const config = presets.reduce(
    (config, preset) => require(preset)(config),
    baseConfig(packageJSON.main)
  )

  return config
}


<|start_filename|>src/config/base.js<|end_filename|>
const webpack = require('webpack')
const path = require('path')

module.exports = function (entry) {
  entry = entry || 'index.js'

  return {
    entry: [
      './' + path.join('.', entry)
    ],
    output: {
      path: process.cwd(),
      filename: 'bundle.js',
      publicPath: '/'
    },
    module: {
      loaders: []
    },
    plugins: [
      new webpack.optimize.OccurenceOrderPlugin(),
      new webpack.NoErrorsPlugin()
    ]
  }
}


<|start_filename|>src/config/presets.js<|end_filename|>
module.exports = function findPresets(dependencies) {
  return Object.keys(dependencies)
    .filter(dep => /webpack-preset-.*/.test(dep))
}


<|start_filename|>src/server.js<|end_filename|>
const path = require('path')
const fs = require('fs')

const express = require('express')
const webpack = require('webpack')

const buildConfig = require('./config')

const app = express()
const config = buildConfig()
const compiler = webpack(config)

app.use(require('webpack-dev-middleware')(compiler, {
  noInfo: true,
  stats: { colors: true },
  publicPath: config.output.publicPath
}))

app.use(require('webpack-hot-middleware')(compiler))

try {
  fs.accessSync('./static/index.html', fs.R_OK)
  app.use((req, res) => res.sendFile('./static/index.html'))
} catch (e) {
  app.use((req, res) => res.sendFile(path.join(__dirname, '../static/index.html')))
}

app.listen(3000, (err) => {
  /*eslint-disable no-console */
  if (err) {
    console.error(err)
  } else {
    console.info(`==> 🌎  listening on port 3000`)
  }
  /*eslint-enable no-console */
})


<|start_filename|>bin/webpack-preset.js<|end_filename|>
#!/usr/bin/env node

require('../src/server');


<|start_filename|>packages/webpack-preset-babel/index.js<|end_filename|>
module.exports = function babelPreset(config) {
  config.module.loaders.push({
    test: /\.jsx?$/,
    exclude: /(node_modules|bower_components)/,
    loader: 'babel',
    query: {
      presets: [],
      plugins: ['transform-runtime']
    }
  });

  return config;
};


<|start_filename|>src/config/json.js<|end_filename|>
const path = require('path')
const fs = require('fs')

module.exports = function loadPackageJSON() {
  const packageJSONPath = path.join(process.cwd(), 'package.json')
  return JSON.parse(fs.readFileSync(packageJSONPath))
}


<|start_filename|>packages/webpack-preset-babel-stage-2/index.js<|end_filename|>
module.exports = function babelPreset(config) {
  config.module.loaders
    .filter(loader => loader.loader == 'babel')[0]
    .query.presets.push('stage-2');

  return config;
};


<|start_filename|>packages/webpack-preset-hmr/index.js<|end_filename|>
const webpack = require('webpack')

module.exports = function hmrPreset(config) {
  config.entry.push('webpack-hot-middleware/client')
  config.plugins.push(new webpack.HotModuleReplacementPlugin())

  return config;
};


<|start_filename|>packages/webpack-preset-hmr/package.json<|end_filename|>
{
  "name": "webpack-preset-hmr",
  "version": "0.2.0",
  "description": "Zero config hot module reloading!",
  "author": "<NAME> <<EMAIL>>",
  "homepage": "https://github.com/webpack-preset/webpack-preset/tree/master/packages/webpack-preset-hmr",
  "license": "MIT",
  "repository": "https://github.com/webpack-preset/webpack-preset/tree/master/packages/webpack-preset-hmr",
  "main": "index.js",
  "dependencies": {
    "webpack": "^1.12.11"
  }
}


<|start_filename|>package.json<|end_filename|>
{
  "name": "webpack-preset",
  "version": "0.2.0",
  "description": "Zero config webpack-powered development!",
  "author": "<NAME> <<EMAIL>>",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "https://github.com/webpack-preset/webpack-preset.git"
  },
  "homepage": "https://github.com/webpack-preset/webpack-preset",
  "main": "index.js",
  "bin": "./bin/webpack-preset.js",
  "files": [
    "README.md",
    "src/*",
    "static/*",
    "bin/*"
  ],
  "scripts": {
    "start": "node ./bin/webpack-preset.js",
    "lint": "eslint src",
    "test": "npm run lint"
  },
  "dependencies": {
    "express": "^4.13.3",
    "webpack": "^1.12.11",
    "webpack-dev-middleware": "^1.4.0",
    "webpack-hot-middleware": "^2.6.0"
  },
  "devDependencies": {
    "babel-eslint": "^5.0.0-beta6",
    "eslint": "^1.10.3",
    "eslint-config-rackt": "^1.1.1",
    "lerna": "2.0.0-beta.20"
  }
}
