mirror of
https://github.com/flarum/core.git
synced 2025-05-16 04:09:41 +02:00
Initial commit
This commit is contained in:
commit
2b80a9913c
55
js-packages/webpack-config/index.js
Normal file
55
js-packages/webpack-config/index.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
|
||||||
|
module.exports = function(options = {}) {
|
||||||
|
const config = {
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.js$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
use: {
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
presets: ['@babel/preset-env', '@babel/preset-react'],
|
||||||
|
plugins: [
|
||||||
|
['@babel/plugin-transform-runtime'],
|
||||||
|
['@babel/plugin-proposal-class-properties'],
|
||||||
|
['@babel/plugin-transform-react-jsx', {pragma: 'm'}]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (options.compat) {
|
||||||
|
config.resolve = config.resolve || {};
|
||||||
|
config.resolve.modules = [
|
||||||
|
path.resolve(process.cwd(), 'src'),
|
||||||
|
path.resolve(process.cwd(), '../lib'),
|
||||||
|
path.resolve(process.cwd(), 'node_modules'),
|
||||||
|
'node_modules'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.compatPrefix) {
|
||||||
|
config.resolve = config.resolve || {};
|
||||||
|
config.resolve.alias = {
|
||||||
|
[options.compatPrefix]: '.'
|
||||||
|
};
|
||||||
|
|
||||||
|
config.externals = [
|
||||||
|
function(context, request, callback) {
|
||||||
|
let matches;
|
||||||
|
if ((matches = /^flarum\/(.+)$/.exec(request)) && request.substr(0, options.compatPrefix.length) !== options.compatPrefix) {
|
||||||
|
return callback(null, 'root flarum.compat[\'' + matches[1] + '\']');
|
||||||
|
}
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return config;
|
||||||
|
};
|
20
js-packages/webpack-config/package.json
Normal file
20
js-packages/webpack-config/package.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "flarum-webpack-config",
|
||||||
|
"version": "0.1.0-beta.4",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"author": "Toby Zerner",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/core": "^7.0.0-beta.39",
|
||||||
|
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.39",
|
||||||
|
"@babel/plugin-transform-react-jsx": "^7.0.0-beta.39",
|
||||||
|
"@babel/plugin-transform-runtime": "^7.0.0-beta.39",
|
||||||
|
"@babel/preset-env": "^7.0.0-beta.39",
|
||||||
|
"@babel/preset-react": "^7.0.0-beta.39",
|
||||||
|
"@babel/runtime": "^7.0.0-beta.39",
|
||||||
|
"babel-loader": "^8.0.0-beta.0",
|
||||||
|
"webpack": "^4.0.0-beta.0",
|
||||||
|
"webpack-cli": "^2.0.0"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user