mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
Add documentation
This commit is contained in:
22
js-packages/webpack-config/LICENSE
Executable file
22
js-packages/webpack-config/LICENSE
Executable file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 Toby Zerner
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
14
js-packages/webpack-config/README.md
Executable file
14
js-packages/webpack-config/README.md
Executable file
@@ -0,0 +1,14 @@
|
||||
**Webpack config for Flarum JavaScript compilation.**
|
||||
|
||||
This package generates a [Webpack](https://webpack.js.org) config object that will compile JavaScript for use in Flarum. Example usage:
|
||||
|
||||
```js
|
||||
// webpack.config.js
|
||||
var config = require('flarum-webpack-config');
|
||||
|
||||
module.exports = config(options);
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
* `compatPrefix` Old-style module prefix (eg. `flarum/sticky`) to alias. Setting this will also enable importing old-style core modules (eg. `import foo from 'flarum/foo'`).
|
@@ -21,25 +21,31 @@ module.exports = function(options = {}) {
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
// 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'
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
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) {
|
||||
// Strip the old-style module prefix from non-relative-path imports by
|
||||
// aliasing it to nothing.
|
||||
config.resolve = config.resolve || {};
|
||||
config.resolve.alias = {
|
||||
[options.compatPrefix]: '.'
|
||||
};
|
||||
|
||||
// Support importing old-style core modules.
|
||||
config.externals = [
|
||||
function(context, request, callback) {
|
||||
let matches;
|
||||
|
Reference in New Issue
Block a user