Skip to content

Instantly share code, notes, and snippets.

@mgenov
Last active January 5, 2017 14:29
Show Gist options
  • Save mgenov/be76b14b8b960fa170239f4981f41c88 to your computer and use it in GitHub Desktop.
Save mgenov/be76b14b8b960fa170239f4981f41c88 to your computer and use it in GitHub Desktop.
webpack + index.js
import angular from 'angular'
/**
* `require` all modules in the given webpack context
*/
function requireAll(context) {
context.keys().forEach(context);
}
// Collect all angular modules
requireAll(require.context(
'./src',
/* use subdirectories: */ true,
/^(?!.*(spec.js$|e2e.js)).*\.js$/
));
requireAll(require.context(
'./src',
/* use subdirectories: */ true,
/\.html$/
));
var webpack = require('webpack')
var path = require('path')
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
context: __dirname,
entry: {
app: './index.js',
vendor: [
'jquery',
'angular'
]
},
output: {
path: __dirname + '/build/assets',
filename: 'admin.bundle.js',
publicPath: "./assets/"
},
module: {
loaders: [
{
test: /\.js$/,
exclude: [/node_modules/, /vendor/],
loader: 'babel-loader',
query: {
presets: ['es2015']
}
},
{
test: /\.css$/,
loader: "css-loader",
options: { relativeUrls: false }
},
{
test: /\.html$/,
loader: "ng-cache?prefix=[dir]&-url"
},
{
test: /\.(jp?g|png|gif|svg)$/i,
loader:'file'
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: "file",
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/octet-stream"
}
]
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
new ExtractTextPlugin("admin.bundle.css"),
new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.bundle.js")
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment