Bundle 3rd party libs into seperate chunk
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
<link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet">
|
||||
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="shortcut icon" href="images/favicon.ico">
|
||||
|
||||
<script src="vendor/jquery/jquery.min.js"></script>
|
||||
<script src="commons.chunk.js"></script>
|
||||
<script src="vendor.uhk.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Google Tag Manager -->
|
||||
@@ -25,8 +25,6 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
||||
|
||||
<main-app></main-app>
|
||||
|
||||
<script src="vendor/bootstrap/js/bootstrap.min.js"></script> <!-- TODO remove in near future -->
|
||||
<script src="vendor/select2/js/select2.full.min.js"></script>
|
||||
<script src="uhk.js"></script>
|
||||
<script src="app.uhk.js"></script> <!-- This should be moved to the head -->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
// var webpack = require("webpack");
|
||||
var webpack = require("webpack");
|
||||
var SvgStore = require('webpack-svgstore-plugin');
|
||||
var webpackFailPlugin = require('webpack-fail-plugin');
|
||||
var CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
var path = require('path');
|
||||
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
|
||||
|
||||
var rootDir = path.resolve(__dirname, '../');
|
||||
|
||||
module.exports = {
|
||||
entry: ['core-js', 'zone.js', './src/main.ts'],
|
||||
entry: {
|
||||
app: ['core-js', 'zone.js', './src/main.ts'],
|
||||
vendor: ['jquery', 'bootstrap', 'select2']
|
||||
},
|
||||
output: {
|
||||
path: rootDir + "/dist",
|
||||
filename: "uhk.js"
|
||||
filename: "[name].uhk.js"
|
||||
},
|
||||
devtool: 'source-map',
|
||||
resolve: {
|
||||
extensions: ['', '.webpack.js', '.web.js', '.ts', '.js'],
|
||||
modules: [path.join(rootDir, "node_modules")]
|
||||
modules: [path.join(rootDir, "node_modules")],
|
||||
alias: {
|
||||
jquery: 'jquery/dist/jquery.min.js',
|
||||
select2: 'select2/dist/js/select2.full.min.js'
|
||||
}
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
@@ -25,7 +33,8 @@ module.exports = {
|
||||
test: /\.scss$/,
|
||||
exclude: /node_modules/,
|
||||
loaders: ['raw-loader', 'sass-loader']
|
||||
}
|
||||
},
|
||||
{ test: /jquery/, loader: 'expose?$!expose?jQuery' }
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
@@ -38,37 +47,36 @@ module.exports = {
|
||||
}
|
||||
}),
|
||||
webpackFailPlugin,
|
||||
new CopyWebpackPlugin([
|
||||
{ from: './src/*.html', flatten: true },
|
||||
{ from: './src/*.js', flatten: true },
|
||||
new CopyWebpackPlugin(
|
||||
[
|
||||
{ from: './src/*.html', flatten: true },
|
||||
{ from: './src/*.js', flatten: true },
|
||||
{
|
||||
from: 'node_modules/font-awesome/css/font-awesome.min.css',
|
||||
to: 'vendor/font-awesome/css/font-awesome.min.css'
|
||||
},
|
||||
{
|
||||
from: 'node_modules/font-awesome/fonts',
|
||||
to: 'vendor/font-awesome/fonts'
|
||||
},
|
||||
{
|
||||
from: 'node_modules/bootstrap/dist/',
|
||||
to: 'vendor/bootstrap'
|
||||
},
|
||||
{
|
||||
from: 'images',
|
||||
to: 'images'
|
||||
},
|
||||
],
|
||||
{
|
||||
from: 'node_modules/font-awesome/css/font-awesome.min.css',
|
||||
to: 'vendor/font-awesome/css/font-awesome.min.css'
|
||||
},
|
||||
{
|
||||
from: 'node_modules/font-awesome/fonts',
|
||||
to: 'vendor/font-awesome/fonts'
|
||||
},
|
||||
{
|
||||
from: 'node_modules/bootstrap/dist',
|
||||
to: 'vendor/bootstrap'
|
||||
},
|
||||
{
|
||||
from: 'node_modules/jquery/dist/jquery.min.*',
|
||||
to: 'vendor/jquery',
|
||||
flatten: true
|
||||
},
|
||||
{
|
||||
from: 'node_modules/select2/dist',
|
||||
to: 'vendor/select2'
|
||||
},
|
||||
{
|
||||
from: 'images',
|
||||
to: 'images'
|
||||
},
|
||||
], {
|
||||
ignore: ['*.config.js']
|
||||
})
|
||||
}
|
||||
),
|
||||
new webpack.ProvidePlugin({
|
||||
$: "jquery",
|
||||
jQuery: "jquery"
|
||||
}),
|
||||
new CommonsChunkPlugin("commons.chunk.js")
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user