mirror of
https://github.com/flarum/framework.git
synced 2024-11-22 13:56:36 +08:00
Fix Flarum on iOS 10 and below (#9)
* Ignore .vscode folder * Add Prettier config * Change author to 'Flarum Team' * Bump deps to latest version * Format with prettier; add `loose` where needed * Don't exclude node modules from Babel processing
This commit is contained in:
parent
a6cc7d3742
commit
8c2642b2f2
1
js-packages/webpack-config/.gitignore
vendored
1
js-packages/webpack-config/.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
node_modules
|
node_modules
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
.vscode
|
||||||
|
|
6
js-packages/webpack-config/.prettierrc.json
Normal file
6
js-packages/webpack-config/.prettierrc.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"printWidth": 150,
|
||||||
|
"singleQuote": true,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"trailingComma": "es5"
|
||||||
|
}
|
|
@ -2,85 +2,89 @@ 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 = {}) {
|
||||||
return {
|
return {
|
||||||
// Set up entry points for each of the forum + admin apps, but only
|
// Set up entry points for each of the forum + admin apps, but only
|
||||||
// if they exist.
|
// if they exist.
|
||||||
entry: function() {
|
entry: (function () {
|
||||||
const entries = {};
|
const entries = {};
|
||||||
|
|
||||||
for (const app of ['forum', 'admin']) {
|
for (const app of ['forum', 'admin']) {
|
||||||
const file = path.resolve(process.cwd(), app+'.js');
|
const file = path.resolve(process.cwd(), app + '.js');
|
||||||
if (fs.existsSync(file)) {
|
if (fs.existsSync(file)) {
|
||||||
entries[app] = file;
|
entries[app] = file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return entries;
|
return entries;
|
||||||
}(),
|
})(),
|
||||||
|
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
exclude: /node_modules/,
|
|
||||||
use: {
|
use: {
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
options: {
|
options: {
|
||||||
presets: [
|
presets: [
|
||||||
['@babel/preset-env', {modules: false, loose: true}],
|
[
|
||||||
['@babel/preset-react']
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
modules: false,
|
||||||
|
loose: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
['@babel/preset-react'],
|
||||||
],
|
],
|
||||||
plugins: [
|
plugins: [
|
||||||
['@babel/plugin-transform-runtime', {useESModules: true}],
|
['@babel/plugin-transform-runtime', { useESModules: true }],
|
||||||
['@babel/plugin-proposal-class-properties'],
|
['@babel/plugin-proposal-class-properties', { loose: true }],
|
||||||
['@babel/plugin-transform-react-jsx', {pragma: 'm'}],
|
['@babel/plugin-proposal-private-methods', { loose: true }],
|
||||||
['@babel/plugin-transform-object-assign']
|
['@babel/plugin-transform-react-jsx', { pragma: 'm' }],
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(process.cwd(), 'dist'),
|
path: path.resolve(process.cwd(), 'dist'),
|
||||||
library: 'module.exports',
|
library: 'module.exports',
|
||||||
libraryTarget: 'assign',
|
libraryTarget: 'assign',
|
||||||
devtoolNamespace: require(path.resolve(process.cwd(), 'package.json')).name
|
devtoolNamespace: require(path.resolve(process.cwd(), 'package.json')).name,
|
||||||
},
|
},
|
||||||
|
|
||||||
externals: [
|
externals: [
|
||||||
{
|
{
|
||||||
'@flarum/core/forum': 'flarum.core',
|
'@flarum/core/forum': 'flarum.core',
|
||||||
'@flarum/core/admin': 'flarum.core',
|
'@flarum/core/admin': 'flarum.core',
|
||||||
'jquery': 'jQuery',
|
jquery: 'jQuery',
|
||||||
},
|
},
|
||||||
|
|
||||||
function() {
|
(function () {
|
||||||
const externals = {};
|
const externals = {};
|
||||||
|
|
||||||
if (options.useExtensions) {
|
if (options.useExtensions) {
|
||||||
for (const extension of options.useExtensions) {
|
for (const extension of options.useExtensions) {
|
||||||
externals['@'+extension] =
|
externals['@' + extension] = externals['@' + extension + '/forum'] = externals['@' + extension + '/admin'] =
|
||||||
externals['@'+extension+'/forum'] =
|
"flarum.extensions['" + extension + "']";
|
||||||
externals['@'+extension+'/admin'] = "flarum.extensions['"+extension+"']";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return externals;
|
return externals;
|
||||||
}(),
|
})(),
|
||||||
|
|
||||||
// Support importing old-style core modules.
|
// 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))) {
|
||||||
return callback(null, 'root flarum.core.compat[\'' + matches[1] + '\']');
|
return callback(null, "root flarum.core.compat['" + matches[1] + "']");
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
devtool: 'source-map'
|
devtool: 'source-map',
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
11031
js-packages/webpack-config/package-lock.json
generated
11031
js-packages/webpack-config/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -3,20 +3,24 @@
|
||||||
"version": "0.1.0-beta.10",
|
"version": "0.1.0-beta.10",
|
||||||
"description": "Webpack config for Flarum JavaScript compilation.",
|
"description": "Webpack config for Flarum JavaScript compilation.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"author": "Toby Zerner",
|
"author": "Flarum Team",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"webpack": "^4.0.0"
|
"webpack": "^4.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.0.0",
|
"@babel/core": "^7.14.0",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.0.0",
|
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
||||||
"@babel/plugin-transform-object-assign": "^7.0.0",
|
"@babel/plugin-proposal-private-methods": "^7.13.0",
|
||||||
"@babel/plugin-transform-react-jsx": "^7.0.0",
|
"@babel/plugin-transform-object-assign": "^7.12.13",
|
||||||
"@babel/plugin-transform-runtime": "^7.0.0",
|
"@babel/plugin-transform-react-jsx": "^7.13.12",
|
||||||
"@babel/preset-env": "^7.0.0",
|
"@babel/plugin-transform-runtime": "^7.13.15",
|
||||||
"@babel/preset-react": "^7.0.0",
|
"@babel/preset-env": "^7.14.0",
|
||||||
"@babel/runtime": "^7.0.0",
|
"@babel/preset-react": "^7.13.13",
|
||||||
"babel-loader": "^8.0.0"
|
"@babel/runtime": "^7.14.0",
|
||||||
|
"babel-loader": "^8.2.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"prettier": "^2.2.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user