Skip to content

Commit 1d5bd04

Browse files
committed
Merge branch 'release/0.3.5'
2 parents e8a8087 + 80136b2 commit 1d5bd04

File tree

5 files changed

+31
-63
lines changed

5 files changed

+31
-63
lines changed

conf/webpack.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const
1010
AutoPrefixer = require('autoprefixer'),
1111
WebpackNotifierPlugin = require('webpack-notifier'),
1212
BowerWebpackPlugin = require('bower-webpack-plugin'),
13+
ProgressBarPlugin = require('progress-bar-webpack-plugin'),
1314
ExtractTextPlugin = require('extract-text-webpack-plugin');
1415

1516
// Built-in modules
@@ -135,8 +136,7 @@ if (config.production) {
135136
chunks: false,
136137
chunkModules: false,
137138
modules: false,
138-
children: true,
139-
version: true,
139+
children: false,
140140
cached: false,
141141
cachedAssets: false,
142142
reasons: false,
@@ -166,14 +166,7 @@ if (!config.production) {
166166
webpack_config.devtool = 'cheap-module-eval-source-map';
167167

168168
webpack_config.plugins.push(
169-
// Progress
170-
new webpack.ProgressPlugin((percentage, msg) => {
171-
percentage = Math.round(percentage * 100);
172-
173-
elixir.Log.message(
174-
`${$.util.colors.green(`${percentage}%`)} ---> ${$.util.colors.blue(msg)}`
175-
);
176-
})
169+
new ProgressBarPlugin()
177170
);
178171
}
179172

index.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,23 @@ const
1515
*/
1616
const
1717
$ = elixir.Plugins,
18-
config = elixir.config,
1918
taskName = 'webpack';
2019

2120
/**
2221
* Built-in modules
2322
*/
2423
const
25-
prepGulpPaths = require('./lib/GulpPaths'),
24+
{GulpPaths, versionPath} = require('./lib/GulpPaths'),
2625
isVersioning = require('./lib/IsVersioning'),
2726
prepareEntry = require('./lib/EntryPaths'),
28-
saveFiles = require('./lib/SaveFiles'),
2927
isWatch = require('./lib/IsWatch');
3028

3129
/**
3230
* Webpack spec
3331
*/
3432
elixir.extend(taskName, function (src, options, globalVars) {
35-
let paths = prepGulpPaths(src),
33+
let paths = GulpPaths(src),
34+
globalConfig = Object.assign({}, webpack_config),
3635
entry = prepareEntry(src);
3736

3837
/**
@@ -45,7 +44,7 @@ elixir.extend(taskName, function (src, options, globalVars) {
4544

4645
// Merge options
4746
options = _.mergeWith(
48-
webpack_config,
47+
globalConfig,
4948
options,
5049
{entry, watch: isWatch()},
5150
(objValue, srcValue) => {
@@ -56,23 +55,14 @@ elixir.extend(taskName, function (src, options, globalVars) {
5655
);
5756

5857
if (isVersioning()) {
59-
options.output.publicPath = options.output.publicPath
60-
61-
// Add leading slash if missing
62-
.replace(/^\/?/, '/')
63-
64-
// insert build folder before js output
65-
.replace(
66-
new RegExp(config.js.outputFolder),
67-
`${config.versioning.buildFolder}/${config.js.outputFolder}`
68-
);
58+
options.output.publicPath = versionPath(options.output.publicPath);
6959
}
7060

7161
/**
7262
* Webpack task
7363
*/
7464
new elixir.Task(taskName, function () {
75-
this.log(paths.src, saveFiles(src, paths));
65+
this.recordStep('Building js files');
7666

7767
webpack(options, (err, stats) => {
7868
if (err) {
@@ -81,7 +71,7 @@ elixir.extend(taskName, function (src, options, globalVars) {
8171

8272
$.util.log(stats.toString(webpack_config.stats));
8373
});
84-
});
74+
}, paths);
8575

8676
/**
8777
* If watch task is triggered, then we should start webpack task only once

lib/GulpPaths.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
const
44
_ = require('lodash'),
5-
elixir = require('laravel-elixir');
5+
elixir = require('laravel-elixir'),
6+
isVersioning = require('../lib/IsVersioning');
67

78
const config = elixir.config;
89

@@ -13,15 +14,28 @@ const config = elixir.config;
1314
* @param {string|null} baseDir
1415
* @param {string|null} output
1516
*/
16-
module.exports = (src, baseDir, output) => {
17+
module.exports.GulpPaths = (src, baseDir, output) => {
1718
baseDir = baseDir || config.get('assets.js.folder');
1819
output = output || config.get('public.js.outputFolder');
1920

2021
if (_.isObject(src)) {
2122
src = _.values(src);
2223
}
2324

25+
if (isVersioning()) {
26+
output = this.versionPath(output);
27+
}
28+
2429
return new elixir.GulpPaths()
2530
.src(src, baseDir)
26-
.output(output, 'app.js');
27-
};
31+
.output(output);
32+
};
33+
34+
module.exports.versionPath = outputPath => outputPath
35+
// Add leading slash if missing
36+
.replace(/^\/?/, '/')
37+
// insert build folder before js output
38+
.replace(
39+
new RegExp(config.js.outputFolder),
40+
`${config.versioning.buildFolder}/${config.js.outputFolder}`
41+
);

lib/SaveFiles.js

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

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "laravel-elixir-webpack-advanced",
3-
"version": "0.3.4",
3+
"version": "0.3.5",
44
"description": "Laravel Elixir Webpack Extension (improved)",
55
"main": "index.js",
66
"scripts": {
@@ -29,9 +29,10 @@
2929
"bower-webpack-plugin": "^0.1.9",
3030
"css-loader": "^0.23.0",
3131
"extract-text-webpack-plugin": "^1.0.0",
32-
"file-loader": "^0.8.5",
32+
"file-loader": "^0.9.0",
3333
"lodash": "^4.0.0",
3434
"postcss-loader": "^0.9.1",
35+
"progress-bar-webpack-plugin": "^1.8.0",
3536
"resolve-url-loader": "^1.4.2",
3637
"rimraf": "^2.4.4",
3738
"sass-loader": "^3.1.2",

0 commit comments

Comments
 (0)