Skip to content

Commit cc7fa85

Browse files
committed
chore(dev) ~ moving scripts to head with defer
1 parent 7bfba74 commit cc7fa85

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

config/webpack.common.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ const helpers = require('./helpers');
1111
// problem with copy-webpack-plugin
1212
const AssetsPlugin = require('assets-webpack-plugin');
1313
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
14+
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
1415
const CopyWebpackPlugin = require('copy-webpack-plugin');
1516
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
1617
const HtmlElementsPlugin = require('./html-elements-plugin');
1718
const HtmlWebpackPlugin = require('html-webpack-plugin');
1819
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
20+
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
1921

2022
/*
2123
* Webpack Constants
@@ -173,7 +175,7 @@ module.exports = function (options) {
173175
* See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
174176
* See: https://github.com/webpack/docs/wiki/optimization#multi-page-app
175177
*/
176-
new webpack.optimize.CommonsChunkPlugin({
178+
new CommonsChunkPlugin({
177179
name: ['polyfills', 'vendor'].reverse()
178180
}),
179181

@@ -198,15 +200,12 @@ module.exports = function (options) {
198200
*
199201
* See: https://www.npmjs.com/package/copy-webpack-plugin
200202
*/
201-
new CopyWebpackPlugin([
202-
{
203-
from: 'src/assets',
204-
to: 'assets',
205-
},
206-
{
207-
from: 'src/meta',
208-
},
209-
]),
203+
new CopyWebpackPlugin([{
204+
from: 'src/assets',
205+
to: 'assets',
206+
}, {
207+
from: 'src/meta',
208+
}, ]),
210209

211210

212211
/*
@@ -221,7 +220,19 @@ module.exports = function (options) {
221220
template: 'src/index.html',
222221
title: METADATA.title,
223222
chunksSortMode: 'dependency',
224-
metadata: METADATA
223+
metadata: METADATA,
224+
inject: 'head'
225+
}),
226+
227+
/*
228+
* Plugin: ScriptExtHtmlWebpackPlugin
229+
* Description: Enhances html-webpack-plugin functionality
230+
* with different deployment options for your scripts including:
231+
*
232+
* See: https://github.com/numical/script-ext-html-webpack-plugin
233+
*/
234+
new ScriptExtHtmlWebpackPlugin({
235+
defaultAttribute: 'defer'
225236
}),
226237

227238
/*

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
"protractor": "^4.0.9",
113113
"raw-loader": "0.5.1",
114114
"rimraf": "^2.5.2",
115+
"script-ext-html-webpack-plugin": "^1.3.2",
115116
"source-map-loader": "^0.1.5",
116117
"string-replace-loader": "1.0.5",
117118
"style-loader": "^0.13.1",

0 commit comments

Comments
 (0)