UNPKG

1.95 kBJavaScriptView Raw
1'use strict';
2
3var _lodash = require('lodash');
4
5var _WebpackTask = require('./WebpackTask');
6
7var _WebpackTask2 = _interopRequireDefault(_WebpackTask);
8
9function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
11/*
12 |----------------------------------------------------------------
13 | Webpack
14 |----------------------------------------------------------------
15 |
16 | This task will allow you to use ES2015 code in any browser.
17 | It leverages Webpack and Buble to transform and compile
18 | your code into a single entry point for the browser.
19 |
20 */
21
22Elixir.webpack = {
23 config: {
24 watch: Elixir.isWatching(),
25 watchOptions: {
26 poll: false,
27 ignored: /node_modules/
28 },
29 devtool: Elixir.config.sourcemaps ? 'eval-cheap-module-source-map' : '',
30 module: {
31 loaders: [{ test: /\.jsx?$/, loader: 'buble', exclude: /node_modules/ }]
32 },
33 stats: {
34 assets: false,
35 version: false
36 },
37 resolve: {
38 extensions: ['', '.js', '.jsx']
39 }
40 },
41
42 mergeConfig: function mergeConfig(newConfig) {
43 return this.config = (0, _lodash.mergeWith)(this.config, newConfig, function (objValue, srcValue) {
44 if ((0, _lodash.isArray)(objValue)) {
45 return objValue.concat(srcValue);
46 }
47 });
48 }
49};
50
51Elixir.extend('webpack', function (scripts, output, baseDir, options) {
52 new _WebpackTask2.default('webpack', getPaths(scripts, baseDir, output), options);
53});
54
55/**
56 * Prep the Gulp src and output paths.
57 *
58 * @param {string|Array} src
59 * @param {string|null} baseDir
60 * @param {string|null} output
61 * @return {GulpPaths}
62 */
63function getPaths(src, baseDir, output) {
64 return new Elixir.GulpPaths().src(src, baseDir || Elixir.config.get('assets.js.folder')).output(output || Elixir.config.get('public.js.outputFolder'), 'all.js');
65}
\No newline at end of file