Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack bundler #290

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ npm-debug.log
enduro_secret.json
/testfolder
/t
/.vscode
1 change: 1 addition & 0 deletions libs/actions/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const action = function () {}
const enduro_server = require(enduro.enduro_path + '/libs/enduro_server/enduro_server')

action.prototype.action = function () {
enduro.config.webpackmode_prod = true;
return enduro_server.run()
}

Expand Down
8 changes: 4 additions & 4 deletions libs/build_tools/gulp_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const event_hooks = require(enduro.enduro_path + '/libs/external_links/event_hoo
const pagelist_generator = require(enduro.enduro_path + '/libs/build_tools/pagelist_generator').init(gulp)
const assets_copier = require(enduro.enduro_path + '/libs/build_tools/assets_copier').init(gulp, browser_sync)
const assets_copier_watch = require(enduro.enduro_path + '/libs/build_tools/assets_copier').watch(gulp, browser_sync)
const js_handler = require(enduro.enduro_path + '/libs/build_tools/js_handler').init(gulp, browser_sync)
const js_webpack_handler = require(enduro.enduro_path + '/libs/build_tools/js_webpack_handler').init(gulp, browser_sync)
const css_handler = require(enduro.enduro_path + '/libs/build_tools/css_handler').init(gulp, browser_sync)
const sprite_icons = require(enduro.enduro_path + '/libs/build_tools/sprite_icons').init(gulp, browser_sync)
// const sprite_icons = require(enduro.enduro_path + '/libs/build_tools/sprite_icons').init(gulp, browser_sync)

gulp.enduro_refresh = function (callback) {
logger.log('Refresh', true, 'enduro_render_events')
Expand Down Expand Up @@ -108,7 +108,7 @@ function browsersync_start (norefresh) {
if (!enduro.flags.nowatch) {

// Watch for any js changes
watch([enduro.project_path + '/assets/js/**/*.js'], () => { gulp.start(js_handler) })
watch([enduro.project_path + '/assets/js/**/*.js'], () => { gulp.start(js_webpack_handler) })

// Watch for sass or less changes
watch(
Expand Down Expand Up @@ -231,7 +231,7 @@ gulp.task('preproduction', ['iconfont', 'png_sprites', pagelist_generator])
// * Production Task
// * No browser_sync, no watching for anything
// * ———————————————————————————————————————————————————————— * //
gulp.task('production', [js_handler, css_handler, 'hbs_templates', assets_copier, 'hbs_helpers'])
gulp.task('production', [js_webpack_handler, css_handler, 'hbs_templates', assets_copier, 'hbs_helpers'])

// * ———————————————————————————————————————————————————————— * //
// * Default Task
Expand Down
64 changes: 0 additions & 64 deletions libs/build_tools/js_handler.js

This file was deleted.

53 changes: 53 additions & 0 deletions libs/build_tools/js_webpack_handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// * ———————————————————————————————————————————————————————— * //
// * JS Task
// * Transpile ES6 to JS
// * ———————————————————————————————————————————————————————— * //
const js_webpack_handler = function () {}
// * ———————————————————————————————————————————————————————— * //
// * JS Task
// * Transpile ES6 to JS
// * ———————————————————————————————————————————————————————— * //
// Gulp imports

// const del = require('del');
const webpackStream = require('webpack-stream');

// * vendor dependencies
const Promise = require('bluebird')
const fs = Promise.promisifyAll(require('fs-extra'))

// * enduro dependencies
const logger = require(enduro.enduro_path + '/libs/logger')

js_webpack_handler.prototype.init = function(gulp, browser_sync) {

// stores task name
const js_webpack_handler_task_name = 'webpack';
gulp.task(js_webpack_handler_task_name, function() {
logger.timestamp('JS compiling started', 'enduro_events');
const build_folder = enduro.project_path + '/' + enduro.config.build_folder;
const webpackConfig = require("./webpack.config.js");
if(enduro.config.webpackmode_prod) webpackConfig.mode = "production"

return gulp.src([
enduro.project_path + '/assets/js/*.js',
'!' + enduro.project_path + '/assets/js/*.min.js',
'!' + enduro.project_path + '/assets/js/handlebars.js'
])
.pipe(webpackStream(webpackConfig))
.on('error', function(err) {
logger.err_blockStart('JS error')
logger.err(err.message)
logger.err_blockEnd()
this.emit('end')
})
.pipe(gulp.dest(build_folder + '/assets/js'))
.pipe(browser_sync.stream())
.on('end', () => {
logger.timestamp('JS compiling finished', 'enduro_events')
})
});
return js_webpack_handler_task_name;
}

module.exports = new js_webpack_handler();
18 changes: 18 additions & 0 deletions libs/build_tools/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

module.exports = {
mode: 'development',
output: {'filename': '[name].js'},
devtool: '#cheap-module-source-map',
module: {
rules: [
{
test: /\.js?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
options: {
presets: ['env']
}
}
]
}
};
Loading