Generate webpack entry points including modules

This commit is contained in:
Alasdair Smith 2018-03-21 12:08:18 +00:00
parent fe65137c05
commit 74099440f3
4 changed files with 20 additions and 5 deletions

View file

@ -49,6 +49,8 @@ TpdsWorker.js
BackgroundJobsWorker.js BackgroundJobsWorker.js
UserAndProjectPopulator.coffee UserAndProjectPopulator.coffee
public/es/modules
public/js/*.js public/js/*.js
public/js/*.map public/js/*.map
public/js/libs/sharejs.js public/js/libs/sharejs.js

View file

@ -161,7 +161,7 @@ block requirejs
if hasFeature('rich-text') if hasFeature('rich-text')
script( script(
src=buildWebpackPath('es/richText.js', {hashedPath:settings.useMinifiedJs}) src=buildWebpackPath('es/rich-text.js', {hashedPath:settings.useMinifiedJs})
type="text/javascript" type="text/javascript"
) )

View file

@ -6,7 +6,7 @@ define ['ide/editor/directives/cmEditor'], () ->
@richTextInit = sinon.stub() @richTextInit = sinon.stub()
@richTextOpenDoc = sinon.stub() @richTextOpenDoc = sinon.stub()
window.Frontend = { window.Frontend = {
richText: { 'rich-text': {
init: @richTextInit, init: @richTextInit,
openDoc: @richTextOpenDoc openDoc: @richTextOpenDoc
} }

View file

@ -1,11 +1,24 @@
const fs = require('fs')
const path = require('path') const path = require('path')
const MODULES_PATH = path.join(__dirname, '/modules')
// Generate a hash of entry points, including modules
const entryPoints = {}
if (fs.existsSync(MODULES_PATH)) {
fs.readdirSync(MODULES_PATH).reduce((acc, module) => {
const entryPath = path.join(MODULES_PATH, module, '/public/es/index.js')
if (fs.existsSync(entryPath)) {
acc[module] = entryPath
}
return acc
}, entryPoints)
}
module.exports = { module.exports = {
// Defines the "entry point(s)" for the application - i.e. the file which // Defines the "entry point(s)" for the application - i.e. the file which
// bootstraps the application // bootstraps the application
entry: { entry: entryPoints,
richText: './public/es/rich-text.js'
},
// Define where and how the bundle will be output to disk // Define where and how the bundle will be output to disk
// Note: webpack-dev-server does not write the bundle to disk, instead it is // Note: webpack-dev-server does not write the bundle to disk, instead it is