Skip to content

Instantly share code, notes, and snippets.

@robey
Last active May 27, 2017 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robey/28ec409aab9d6ac05e53526546ea1eae to your computer and use it in GitHub Desktop.
Save robey/28ec409aab9d6ac05e53526546ea1eae to your computer and use it in GitHub Desktop.
snip of how i use webpack

webpack.config.js

module.exports = {
  entry: [ "./src/jumbotron.ts" ],
  output: {
    path: __dirname + "/site/lib",
    filename: "jumbotron.js",
    library: "jumbotron"
  },
  // skip these node-only modules.
  externals: [
    { "fs": "null" }
    // { "aws-sdk": "null" },
  ],
  node: {
    Buffer: false
  },
  resolve: {
    extensions: [ ".ts", ".js", ".handlebars" ],
    alias: {
      "handlebars": "handlebars/dist/handlebars.js"
    }
  },
  module: {
    loaders: [
      { test: /.json$/, loader: "json-loader" },
      { test: /\.ts$/, loader: "ts-loader" },
      { test: /\.handlebars$/, loader: "handlebars-loader" }
    ]
  }
};

package.json

"scripts": {
  "build": "npm run webpack",
  "clean": "rm -rf lib site/lib",
  "distclean": "npm run clean && rm -rf node_modules",
  "prepublish": "npm run build",
  "test": "npm run build && mocha -R spec --colors lib/test",
  "webpack": "webpack --display-error-details"
},

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "isolatedModules": false,
    "jsx": "react",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "noImplicitAny": true,
    "noImplicitUseStrict": false,
    "noImplicitReturns": true,
    "allowUnreachableCode": false,
    "removeComments": true,
    "rootDir": "src/",
    "outDir": "lib/",
    "declaration": false,
    "preserveConstEnums": true,
    "sourceMap": true,
    "suppressImplicitAnyIndexErrors": true,
    "strictNullChecks": true,
    "lib": [ "ES6", "dom" ]
  },
  "filesGlob": [
    "src/**/*.ts"
  ],
  "compileOnSave": true,
  "buildOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment