mirror of
https://github.com/flarum/framework.git
synced 2024-11-22 09:08:15 +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
|
||||
.DS_Store
|
||||
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 webpack = require('webpack');
|
||||
|
||||
module.exports = function(options = {}) {
|
||||
module.exports = function (options = {}) {
|
||||
return {
|
||||
// Set up entry points for each of the forum + admin apps, but only
|
||||
// if they exist.
|
||||
entry: function() {
|
||||
entry: (function () {
|
||||
const entries = {};
|
||||
|
||||
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)) {
|
||||
entries[app] = file;
|
||||
}
|
||||
}
|
||||
|
||||
return entries;
|
||||
}(),
|
||||
})(),
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
presets: [
|
||||
['@babel/preset-env', {modules: false, loose: true}],
|
||||
['@babel/preset-react']
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
modules: false,
|
||||
loose: true,
|
||||
},
|
||||
],
|
||||
['@babel/preset-react'],
|
||||
],
|
||||
plugins: [
|
||||
['@babel/plugin-transform-runtime', {useESModules: true}],
|
||||
['@babel/plugin-proposal-class-properties'],
|
||||
['@babel/plugin-transform-react-jsx', {pragma: 'm'}],
|
||||
['@babel/plugin-transform-object-assign']
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
['@babel/plugin-transform-runtime', { useESModules: true }],
|
||||
['@babel/plugin-proposal-class-properties', { loose: true }],
|
||||
['@babel/plugin-proposal-private-methods', { loose: true }],
|
||||
['@babel/plugin-transform-react-jsx', { pragma: 'm' }],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
output: {
|
||||
path: path.resolve(process.cwd(), 'dist'),
|
||||
library: 'module.exports',
|
||||
libraryTarget: 'assign',
|
||||
devtoolNamespace: require(path.resolve(process.cwd(), 'package.json')).name
|
||||
devtoolNamespace: require(path.resolve(process.cwd(), 'package.json')).name,
|
||||
},
|
||||
|
||||
externals: [
|
||||
{
|
||||
'@flarum/core/forum': 'flarum.core',
|
||||
'@flarum/core/admin': 'flarum.core',
|
||||
'jquery': 'jQuery',
|
||||
jquery: 'jQuery',
|
||||
},
|
||||
|
||||
function() {
|
||||
(function () {
|
||||
const externals = {};
|
||||
|
||||
if (options.useExtensions) {
|
||||
for (const extension of options.useExtensions) {
|
||||
externals['@'+extension] =
|
||||
externals['@'+extension+'/forum'] =
|
||||
externals['@'+extension+'/admin'] = "flarum.extensions['"+extension+"']";
|
||||
externals['@' + extension] = externals['@' + extension + '/forum'] = externals['@' + extension + '/admin'] =
|
||||
"flarum.extensions['" + extension + "']";
|
||||
}
|
||||
}
|
||||
|
||||
return externals;
|
||||
}(),
|
||||
})(),
|
||||
|
||||
// Support importing old-style core modules.
|
||||
function(context, request, callback) {
|
||||
function (context, request, callback) {
|
||||
let matches;
|
||||
if ((matches = /^flarum\/(.+)$/.exec(request))) {
|
||||
return callback(null, 'root flarum.core.compat[\'' + matches[1] + '\']');
|
||||
return callback(null, "root flarum.core.compat['" + matches[1] + "']");
|
||||
}
|
||||
callback();
|
||||
}
|
||||
},
|
||||
],
|
||||
|
||||
devtool: 'source-map'
|
||||
devtool: 'source-map',
|
||||
};
|
||||
};
|
||||
|
|
11033
js-packages/webpack-config/package-lock.json
generated
11033
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",
|
||||
"description": "Webpack config for Flarum JavaScript compilation.",
|
||||
"main": "index.js",
|
||||
"author": "Toby Zerner",
|
||||
"author": "Flarum Team",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"webpack": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.0.0",
|
||||
"@babel/plugin-proposal-class-properties": "^7.0.0",
|
||||
"@babel/plugin-transform-object-assign": "^7.0.0",
|
||||
"@babel/plugin-transform-react-jsx": "^7.0.0",
|
||||
"@babel/plugin-transform-runtime": "^7.0.0",
|
||||
"@babel/preset-env": "^7.0.0",
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"@babel/runtime": "^7.0.0",
|
||||
"babel-loader": "^8.0.0"
|
||||
"@babel/core": "^7.14.0",
|
||||
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
||||
"@babel/plugin-proposal-private-methods": "^7.13.0",
|
||||
"@babel/plugin-transform-object-assign": "^7.12.13",
|
||||
"@babel/plugin-transform-react-jsx": "^7.13.12",
|
||||
"@babel/plugin-transform-runtime": "^7.13.15",
|
||||
"@babel/preset-env": "^7.14.0",
|
||||
"@babel/preset-react": "^7.13.13",
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"babel-loader": "^8.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "^2.2.1"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user