Skip to content

Instantly share code, notes, and snippets.

@acodesmith
Last active December 14, 2016 19:43
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 acodesmith/d04f1ce998c71363fd59cf5a05b4736c to your computer and use it in GitHub Desktop.
Save acodesmith/d04f1ce998c71363fd59cf5a05b4736c to your computer and use it in GitHub Desktop.
Example Webpack
//Webpack and NPM plugins
var webpack = require('webpack');
var glob = require("glob");
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
//Folder Locations
var APP_DIR = path.resolve(__dirname, 'src');
var BUILD_DIR = path.resolve(__dirname, 'dist');
var config = {
//@todo remove for production env
devtool: 'source-map',
entry: {
frontend: APP_DIR + '/app.js',
maps: APP_DIR + '/maps.js',
admin: APP_DIR + '/admin.js'
},
output: {
path: BUILD_DIR,
filename: '[name].js'
},
publicPath: BUILD_DIR,
module : {
loaders : [
{
test: /\.js?$/,
exclude: /(node_modules|bower_components)/,
include : APP_DIR,
loader : 'babel-loader',
query: {
plugins: ['transform-runtime'],
presets: ['stage-2', 'es2015']
}
},{
test: /\.scss$/,
loader: ExtractTextPlugin.extract("style", "css!sass?root=.")
},{
test: /\.jpg$/,
loader: "url-loader?limit=10000&minetype=image/jpg"
},{
test: /\.css$/,
loader: "style-loader!css-loader!postcss-loader"
}
]
},
plugins: [
new ExtractTextPlugin('project-name.css', {
allChunks: true
})
],
resolve: {
modulesDirectories: ['node_modules'],
extensions: ['', '.js', '.scss']
},
eslint: {
configFile: '.eslintrc'
}
};
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment