Skip to content

Instantly share code, notes, and snippets.

@blaflamme
Created August 14, 2015 15:27
Show Gist options
  • Select an option

  • Save blaflamme/97a72bf2eedf729e7c3a to your computer and use it in GitHub Desktop.

Select an option

Save blaflamme/97a72bf2eedf729e7c3a to your computer and use it in GitHub Desktop.
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var SwigWebpackPlugin = require('swig-webpack-plugin');
var node_modules_dir = path.resolve(__dirname, 'node_modules');
var vendors_dir = path.resolve(__dirname, 'src/client/vendors');
var templates = require('./webpack.tmpl.config').templates;
var config = {
addVendor: function (name, path) {
this.resolve.alias[name] = path;
this.module.noParse.push(path);
},
entry: {
app: [
'webpack/hot/dev-server',
path.resolve(__dirname, 'src/client/main.js')
],
vendors: [
path.resolve(__dirname, 'src/client/vendors.js')
],
kendo: [
path.resolve(__dirname, 'src/client/vendors-kendo.js')
]
},
output: {
path: path.resolve(__dirname, 'build'),
filename: '[name].[hash].js'
},
resolve: {
root: path.resolve(__dirname, 'src/client'),
extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx'],
modulesDirectories: ['node_modules'],
alias: {}
},
module: {
noParse: [],
loaders: [{
test: /\.(js|jsx)$/,
exclude: [node_modules_dir],
loader: 'babel'
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css')
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract(
'style',
'css?sourceMap!sass?sourceMap&includePaths[]=' + node_modules_dir
)
}, {
test: /\.(png|jpg|gif|ico)$/,
loader: 'file?name=img/[name].[ext]'
}, {
test: /\.html$/,
loader: 'html'
}, {
test: /\.txt$/,
loader: 'raw'
}, {
test: /\.(woff|woff2|ttf|eot|svg)(\?.*)?$/,
loader: 'file?name=fonts/[name].[ext]'
}]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
_: 'lodash'
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.[hash].js'),
new webpack.optimize.DedupePlugin(),
new webpack.DefinePlugin({
__DEBUG__: true,
__APIURL__: '"http://localhost:6543/v1"',
__LOCALE__: '"fr-CA"'
}),
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('[name].[hash].css', {
allChunks: true
}),
],
node: {
net: 'empty',
dns: 'empty'
}
};
config.addVendor('pace', path.resolve(vendors_dir, 'pace.min.js'));
config.addVendor('messenger', path.resolve(vendors_dir, 'messenger.min.js'));
config.addVendor('messenger-theme', path.resolve(vendors_dir, 'messenger-theme-flat.js'));
config.addVendor('kendo', path.resolve(vendors_dir, 'kendo/js/kendo.custom.min.js'));
if (templates) {
templates.forEach(function(template) {
template.mode = 'develop';
config.plugins.push(new SwigWebpackPlugin(template));
});
};
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment