mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 23:23:52 +08:00
49fa832a9b
Aliasing was only working for the `src` directory, it would not find modules in the `lib` directory. Therefore the easiest way to migrate will be to remove the prefix manually from import statements.
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
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'}]
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
|
|
// For backwards compatibility, search for non-relative-path modules
|
|
// in the `src` and `lib` directories. Also make sure the root node_modules
|
|
// directory is searched, otherwise importing a module from a file
|
|
// inside `lib` won't work.
|
|
resolve: {
|
|
modules: [
|
|
path.resolve(process.cwd(), 'src'),
|
|
path.resolve(process.cwd(), '../lib'),
|
|
path.resolve(process.cwd(), 'node_modules'),
|
|
'node_modules'
|
|
]
|
|
},
|
|
|
|
// Support importing old-style core modules.
|
|
externals: [
|
|
function(context, request, callback) {
|
|
let matches;
|
|
if ((matches = /^flarum\/(.+)$/.exec(request))) {
|
|
return callback(null, 'root flarum.compat[\'' + matches[1] + '\']');
|
|
}
|
|
callback();
|
|
}
|
|
]
|
|
};
|
|
|
|
return config;
|
|
};
|