Skip to content

Instantly share code, notes, and snippets.

@otaviomedeiros
Created May 5, 2017 18:45
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 otaviomedeiros/c249f8b8af0bb24920ebe322fd2d2bff to your computer and use it in GitHub Desktop.
Save otaviomedeiros/c249f8b8af0bb24920ebe322fd2d2bff to your computer and use it in GitHub Desktop.
Webpack build with code splitting
var path = require('path');
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var baseCSS = new ExtractTextPlugin({ filename: "base.css" });
var vendorCSS = new ExtractTextPlugin({ filename: "[name].css", allChunks: true });
var VENDOR = [
"angular",
"angular-aria",
"angular-busy",
"angular-elastic",
"angular-froala",
"angular-local-storage",
"angular-mocks",
"angular-print",
"angular-resource",
"angular-route",
"angular-sanitize",
"angular-stalker",
"angular-translate",
"angular-ui-tree",
"froala-editor",
"highcharts",
"highcharts-ng",
"jquery",
"jquery-stalker",
"moment",
"ng-dialog",
"ng-file-upload",
"ng-infinite-scroll",
"ng-tags-input",
"spectrum-colorpicker",
"underscore"
];
module.exports = {
entry: {
'projectConfiguration.module': './app/projectConfiguration.module.js',
'testManager.module': './app/testManager.module.js',
'panelModuleLoader': './app/panelModuleLoader.js',
'vendor': VENDOR
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, '../kanoah-tests-server/src/main/resources/com/kanoah/testmanager/frontend')
},
module: {
rules: [
{
test: /\.scss$/,
use: baseCSS.extract({
use: 'css-loader!sass-loader!import-glob-loader'
}),
exclude: /node_modules/
},
{
test: /\.css$/,
use: vendorCSS.extract({
use: 'css-loader'
}),
exclude: /app/
},
{
test: /\.(ttf|eot|svg|woff|woff2)$/,
use: 'file-loader?name=fonts/[name].[ext]'
},
{
test: /\.(png|gif)$/,
use: 'file-loader?name=images/[name].[ext]'
}
]
},
plugins: [
baseCSS,
vendorCSS,
new webpack.ProvidePlugin({
$: "jquery",
jQuery: 'jquery',
'window.jQuery': 'jquery',
}),
new CopyWebpackPlugin([
{ from: 'app/kanoahPre.js' },
{ from: 'app/kanoahPost.js' },
{ from: 'node_modules/froala-editor/css/froala_style.min.css' },
]),
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor' })
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment