Skip to content

Commit 357807a

Browse files
author
pqml
committed
Update dependencies
1 parent 37ed7b3 commit 357807a

File tree

14 files changed

+1381
-835
lines changed

14 files changed

+1381
-835
lines changed

main.config.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ const path = require('path')
55
* All file will be passed to your webpack config.
66
* Formatted as { input: output }
77
* paths are relative to your project root (__dirname)
8+
* The builds folder in www/assets is auto cleaned after each build.
89
*/
910
const entries = {
10-
'src/index.js': 'www/assets/bundle.js',
11-
'src/index.less': 'www/assets/bundle.css'
11+
'src/index.js': 'www/assets/builds/bundle.js',
12+
'src/index.less': 'www/assets/builds/bundle.css'
1213
}
1314

1415
/**
@@ -75,6 +76,14 @@ const devServer = {
7576
// Use the proxy opt if you can't use / don't want to use a built-in php serv.
7677
phpBinary: 'php',
7778

79+
// Host used by the php built-in server. Only used when proxy is false.
80+
// Default is localhost.
81+
// On Mac, the default will be [::1] (IPv6 equivalent of localhost)
82+
// See: http://php.net/manual/en/features.commandline.webserver.php#120449
83+
// You might need to change config/config.localhost.php into config.[YOURHOST].php
84+
// In order for kirby-webpack to continue working with your host
85+
phpHost: 'localhost',
86+
7887
// Set this to true to display PHP logs in your terminal
7988
// /!\ does nothing if you use the `proxy` option
8089
logPhpErrors: true,

package.json

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kirby-webpack",
3-
"version": "0.7.5",
3+
"version": "0.8.0",
44
"description": "A kirby starter-kit with modern frontend tools",
55
"main": "index.js",
66
"scripts": {
@@ -30,36 +30,37 @@
3030
"homepage": "https://github.com/brocessing/kirby-webpack#readme",
3131
"devDependencies": {
3232
"@pqml/node-php-server": "^0.3.1",
33-
"autoprefixer": "^7.2.5",
33+
"autoprefixer": "^8.2.0",
3434
"babel-core": "^6.26.0",
35-
"babel-loader": "^7.1.2",
35+
"babel-loader": "^7.1.4",
3636
"babel-plugin-transform-runtime": "^6.23.0",
3737
"babel-preset-env": "^1.6.1",
38-
"browser-sync": "^2.23.5",
39-
"cross-env": "^5.1.3",
40-
"css-loader": "^0.28.9",
41-
"eslint": "^4.16.0",
42-
"eslint-config-standard": "^11.0.0-beta.0",
43-
"eslint-plugin-import": "^2.8.0",
44-
"eslint-plugin-node": "^5.2.1",
45-
"eslint-plugin-promise": "^3.6.0",
38+
"browser-sync": "^2.23.6",
39+
"cross-env": "^5.1.4",
40+
"css-loader": "^0.28.11",
41+
"eslint": "^4.19.1",
42+
"eslint-config-standard": "^11.0.0",
43+
"eslint-plugin-import": "^2.10.0",
44+
"eslint-plugin-node": "^6.0.1",
45+
"eslint-plugin-promise": "^3.7.0",
4646
"eslint-plugin-standard": "^3.0.1",
47-
"extract-text-webpack-plugin": "^3.0.2",
48-
"file-loader": "^1.1.6",
47+
"extract-text-webpack-plugin": "^4.0.0-beta.0",
48+
"file-loader": "^1.1.11",
4949
"fs-extra": "^5.0.0",
5050
"github-download": "^0.5.0",
5151
"kool-shell": "^1.5.0",
52-
"less": "^3.0.0-alpha.3",
53-
"less-loader": "^4.0.5",
54-
"postcss-loader": "^2.0.10",
55-
"progress-bar-webpack-plugin": "^1.10.0",
56-
"resolve-url-loader": "^2.2.1",
57-
"style-loader": "^0.19.1",
52+
"less": "^3.0.1",
53+
"less-loader": "^4.1.0",
54+
"postcss-loader": "^2.1.3",
55+
"progress-bar-webpack-plugin": "^1.11.0",
56+
"resolve-url-loader": "^2.3.0",
57+
"style-loader": "^0.20.3",
5858
"tail": "^1.2.3",
59-
"webpack": "^3.10.0",
60-
"webpack-dev-middleware": "^2.0.4",
61-
"webpack-hot-middleware": "^2.21.0",
62-
"webpack-merge": "^4.1.1"
59+
"uglifyjs-webpack-plugin": "^1.2.4",
60+
"webpack": "^4.5.0",
61+
"webpack-dev-middleware": "^3.1.2",
62+
"webpack-hot-middleware": "^2.21.2",
63+
"webpack-merge": "^4.1.2"
6364
},
6465
"dependencies": {}
6566
}

scripts/webpack-build.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
const startTime = new Date()
22

3+
const fs = require('fs-extra')
4+
const path = require('path')
35
const webpack = require('webpack')
46
const webpackConfig = require('../webpack.config.prod')
57
const ProgressBarPlugin = require('progress-bar-webpack-plugin')
8+
const user = require('./utils/format-config')(require('../main.config.js'))
69

710
const sh = require('kool-shell')()
811
.use(require('kool-shell/plugins/log'))
@@ -19,14 +22,15 @@ compiler.apply(
1922
)
2023

2124
Promise.resolve()
25+
.then(() => fs.remove(path.join(user.paths.kirby.assets, 'builds')))
2226
.then(() => sh.log('Running the webpack compiler...'))
2327
.then(
2428
() =>
2529
new Promise((resolve, reject) => {
2630
compiler.run((err, stats) => {
27-
stats.compilation.modules.forEach((module => {
31+
stats.compilation.modules.forEach(module => {
2832
if (module.error) return reject(module.error)
29-
}))
33+
})
3034
if (!err) resolve(stats)
3135
else reject(err)
3236
})

scripts/webpack-serve.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
const fs = require('fs-extra')
22
const path = require('path')
3+
const os = require('os')
34
const browserSync = require('browser-sync')
45
const webpack = require('webpack')
56
const webpackConfig = require('../webpack.config.dev')
67
const webpackDevMiddleware = require('webpack-dev-middleware')
78
const webpackHotMiddleware = require('webpack-hot-middleware')
89

10+
const isMacOS = (os.platform() === 'darwin')
11+
912
const php = require('@pqml/node-php-server')
1013

1114
const Tail = require('tail').Tail
@@ -52,7 +55,7 @@ function phpInit () {
5255

5356
phpServer = php({
5457
bin: user.devServer.phpBinary || 'php',
55-
host: 'localhost',
58+
host: user.devServer.phpHost || 'localhost',
5659
root: user.paths.www,
5760
verbose: false,
5861
promptBinary: true,
@@ -64,8 +67,8 @@ function phpInit () {
6467
// php server can't be reach through localhost, we have to use [::1]
6568
sh.log('PHP Server started on ' + host + ':' + port + '\n')
6669

67-
if (host === 'localhost') {
68-
sh.warn('\nNode can\'t reach PHP built-in server through localhost.\nProxying [::1]:' + port + ' instead.')
70+
if (isMacOS && host === 'localhost') {
71+
sh.warn('\nOn MacOS / OSX, Node can\'t reach PHP built-in server through localhost.\nProxying [::1]:' + port + ' instead.')
6972
host = '[::1]'
7073
}
7174

webpack.config.common.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const user = require('./scripts/utils/format-config')(require('./main.config.js'))
2+
const { EnvironmentPlugin } = require('webpack')
23

34
const CSSLoaders = [
45
{
@@ -49,7 +50,9 @@ const webpack = {
4950
}
5051
]
5152
},
52-
plugins: []
53+
plugins: [
54+
new EnvironmentPlugin(['NODE_ENV'])
55+
]
5356
}
5457

5558
module.exports = { CSSLoaders, webpack, user }

webpack.config.dev.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const cssLoaders = (
88
{
99
loader: 'style-loader',
1010
options: {
11-
sourceMap: true
11+
sourceMap: true,
12+
singleton: true // avoid CSS Flashing
1213
}
1314
}
1415
].concat(common.CSSLoaders)
@@ -31,6 +32,7 @@ if (user.css.preprocessorLoader) {
3132
}
3233

3334
const devConfig = {
35+
mode: 'development',
3436
entry: user.entries,
3537
module: {
3638
rules: [
@@ -51,6 +53,7 @@ const devConfig = {
5153
},
5254
plugins: [
5355
new webpack.NoEmitOnErrorsPlugin(),
56+
new webpack.NamedModulesPlugin(),
5457
new webpack.HotModuleReplacementPlugin()
5558
],
5659
devtool: '#eval-source-map'

webpack.config.prod.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ const path = require('path')
22
const webpack = require('webpack')
33
const merge = require('webpack-merge')
44
const ExtractTextPlugin = require('extract-text-webpack-plugin')
5+
6+
const UglifyPlugin = require('uglifyjs-webpack-plugin')
7+
58
const common = require('./webpack.config.common')
69
const user = require('./scripts/utils/format-config')(require('./main.config.js'))
710

811
const prodConfig = {
12+
mode: 'production',
913
entry: user.entries,
1014
module: {
1115
rules: [
@@ -19,6 +23,9 @@ const prodConfig = {
1923
]
2024
},
2125
plugins: [
26+
new webpack.LoaderOptionsPlugin({ minimize: true, debug: false }),
27+
new webpack.optimize.ModuleConcatenationPlugin(),
28+
2229
// Extract all css into one file
2330
new ExtractTextPlugin({
2431
filename: (getPath) => {
@@ -34,17 +41,21 @@ const prodConfig = {
3441
}),
3542

3643
// Minification and size optimization
37-
new webpack.DefinePlugin({ 'process.env': { 'NODE_ENV': '"production"' } }),
38-
new webpack.optimize.UglifyJsPlugin({
39-
compress: { warnings: false, screw_ie8: true, drop_console: true },
40-
output: { comments: false },
41-
mangle: { screw_ie8: true },
42-
sourceMap: true
44+
new UglifyPlugin({
45+
sourceMap: true,
46+
parallel: true,
47+
uglifyOptions: {
48+
mangle: true,
49+
keep_classnames: true,
50+
keep_fnames: false,
51+
compress: { inline: false, drop_console: true },
52+
output: { comments: false }
53+
}
4354
}),
55+
4456
new webpack.optimize.OccurrenceOrderPlugin()
4557
],
46-
devtool: '#source-map',
47-
bail: true
58+
devtool: '#source-map'
4859
}
4960

5061
module.exports = merge(common.webpack, prodConfig)

www/assets/bundle.css

Lines changed: 0 additions & 2 deletions
This file was deleted.

www/assets/bundle.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

www/assets/bundle.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)