Skip to content

Instantly share code, notes, and snippets.

@clintwine
Forked from anonymous/weback.config.explained.js
Created November 23, 2017 21:17
Show Gist options
  • Save clintwine/b2b350632338a970a8b851238e882eb8 to your computer and use it in GitHub Desktop.
Save clintwine/b2b350632338a970a8b851238e882eb8 to your computer and use it in GitHub Desktop.
weback.config.explained created by agochinedum - https://repl.it/@agochinedum/webackconfigexplained
/**
* building a webpack 1.0 config file
* this uses the common.js syntax
*
* Loaders enable webpack to process more than just JavaScript files (webpack itself only understands JavaScript).
* They give you the ability to leverage webpack's bundling capabilities for all kinds of files by converting them to valid modules that webpack can process.
*
* webpack loaders transform all types of files into modules that can be included in your application's dependency graph
*
* */
const path = require('path');
module.exports = {
entry : ["./apps.js", "./global.js"], //entry holds list of files we want to include in our build
output : { //output contains the name of the file and path
filename: "bundle.js",
pathname: path.resolve(__dirname + "buildFolder")
},
module : { //to add loaders, we need to create a module key
loaders : [ //we specify Loaders key which is an Arrayt hat holds each loader Object
{
loader : "babel-loader", //this object contains the babel-loader object and its description
test : /\"this is a REGEXP"/, //this is a regexp that tests which files will be run through our loader
exclude : /node_modules/,
query : { //this contains options for this loader ...http//goo.cm?q=react
presets : ['react', 'es2015'] //installed presets
}
},
{
loader : 'jshint-loader', //this object contains the jshint-loader object and its description
test : /\.js$/, //this is a regexp that tests which files will be run through our loader in this case just .js files
exclude : 'node_modules'
}
]
},
resolve : { //resolve lets us specify the kind of files we need to process without typying their extensions everytime
extensions : ['', '.es6', '.js'] //e.g instead of typing require(./app.es6) or require(./global.js), with this here we just type
} //require(./app) or require(./global)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment