mirror of
https://github.com/flarum/framework.git
synced 2025-04-26 22:54:03 +08:00
Update for new JS directory structure + multiple entry points + sourcemaps
This commit is contained in:
parent
49fa832a9b
commit
d67d60c52b
@ -1,8 +1,24 @@
|
|||||||
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
|
|
||||||
module.exports = function(options = {}) {
|
module.exports = function(options = {}) {
|
||||||
const config = {
|
return {
|
||||||
|
// Set up entry points for each of the forum + admin apps, but only
|
||||||
|
// if they exist.
|
||||||
|
entry: function() {
|
||||||
|
const entries = {};
|
||||||
|
|
||||||
|
for (const app of ['forum', 'admin']) {
|
||||||
|
const file = path.resolve(process.cwd(), 'js/' + app + '/index.js');
|
||||||
|
if (fs.existsSync(file)) {
|
||||||
|
entries[app] = file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return entries;
|
||||||
|
}(),
|
||||||
|
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
@ -23,21 +39,31 @@ module.exports = function(options = {}) {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
output: {
|
||||||
|
path: path.resolve(process.cwd(), 'js')
|
||||||
|
},
|
||||||
|
|
||||||
// For backwards compatibility, search for non-relative-path modules
|
// For backwards compatibility, search for non-relative-path modules
|
||||||
// in the `src` and `lib` directories. Also make sure the root node_modules
|
// in the source directories. Also make sure the root node_modules
|
||||||
// directory is searched, otherwise importing a module from a file
|
// directory is searched.
|
||||||
// inside `lib` won't work.
|
|
||||||
resolve: {
|
resolve: {
|
||||||
modules: [
|
modules: [
|
||||||
path.resolve(process.cwd(), 'src'),
|
path.resolve(process.cwd(), 'js/forum'),
|
||||||
path.resolve(process.cwd(), '../lib'),
|
path.resolve(process.cwd(), 'js/admin'),
|
||||||
|
path.resolve(process.cwd(), 'js/common'),
|
||||||
path.resolve(process.cwd(), 'node_modules'),
|
path.resolve(process.cwd(), 'node_modules'),
|
||||||
'node_modules'
|
'node_modules'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
// Support importing old-style core modules.
|
|
||||||
externals: [
|
externals: [
|
||||||
|
{
|
||||||
|
'@flarum/core/forum': 'flarum',
|
||||||
|
'@flarum/core/admin': 'flarum',
|
||||||
|
'jquery': 'jQuery'
|
||||||
|
},
|
||||||
|
|
||||||
|
// Support importing old-style core modules.
|
||||||
function(context, request, callback) {
|
function(context, request, callback) {
|
||||||
let matches;
|
let matches;
|
||||||
if ((matches = /^flarum\/(.+)$/.exec(request))) {
|
if ((matches = /^flarum\/(.+)$/.exec(request))) {
|
||||||
@ -45,8 +71,8 @@ module.exports = function(options = {}) {
|
|||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
};
|
|
||||||
|
|
||||||
return config;
|
devtool: 'source-map'
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user