Преглед изворни кода

Generate webpack entry points including modules

Alasdair Smith пре 8 година
родитељ
комит
74099440f3

+ 2 - 0
services/web/.gitignore

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

+ 1 - 1
services/web/app/views/project/editor.pug

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

+ 1 - 1
services/web/test/unit_frontend/coffee/ide/editor/directives/cmEditorTests.coffee

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

+ 16 - 3
services/web/webpack.config.js

@@ -1,11 +1,24 @@
+const fs = require('fs')
 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 = {
 	// Defines the "entry point(s)" for the application - i.e. the file which
 	// bootstraps the application
-	entry: {
-		richText: './public/es/rich-text.js'
-	},
+	entry: entryPoints,
 
 	// 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