Skip to content

Instantly share code, notes, and snippets.

@madx
Created September 15, 2015 13:55
Show Gist options
  • Select an option

  • Save madx/53853c3d7b527744917f to your computer and use it in GitHub Desktop.

Select an option

Save madx/53853c3d7b527744917f to your computer and use it in GitHub Desktop.

Revisions

  1. madx created this gist Sep 15, 2015.
    70 changes: 70 additions & 0 deletions webpack.server.config.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,70 @@
    const path = require("path")
    const fs = require("fs")

    // -- Webpack configuration --

    const config = {}

    // Application entry point
    config.entry = "./src/server/index.js"

    // We build for node
    config.target = "node"

    // Node module dependencies should not be bundled
    config.externals = fs.readdirSync("node_modules")
    .reduce(function(acc, mod) {
    if (mod === ".bin") {
    return acc
    }

    acc[mod] = "commonjs " + mod
    return acc
    }, {})

    // We are outputting a real node app!
    config.node = {
    console: false,
    global: false,
    process: false,
    Buffer: false,
    __filename: false,
    __dirname: false,
    }

    // Output files in the build/ folder
    config.output = {
    path: path.join(__dirname, "build"),
    filename: "[name].js",
    }

    config.resolve = {
    extensions: [
    "",
    ".js",
    ".json",
    ],
    }

    config.module = {}

    config.module.loaders = [

    // Use babel and eslint to build and validate JavaScript
    {
    test: /\.js$/,
    exclude: /node_modules/,
    loaders: [
    "babel?{stage:0,jsxPragma:'this.createElement'}",
    "eslint",
    ],
    },

    // Allow loading of JSON files
    {
    test: /\.json$/,
    loader: "json",
    },
    ]

    module.exports = config