-
-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(aurelia): Add an Aurelia plugin option and expose module resolve #248
base: main
Are you sure you want to change the base?
Changes from 1 commit
9b5cc67
785e8ae
fbed96d
7285fdd
720abcd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -629,6 +629,18 @@ const publicApi = { | |
return this; | ||
}, | ||
|
||
/** | ||
* If enabled, the Aurelia plugin is enabled | ||
* | ||
* @param {function} aureliaLoaderOptionsCallback | ||
* @returns {exports} | ||
*/ | ||
enableAurelia(aureliaLoaderOptionsCallback = () => {}) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's a plugin, we try to include that in the name to help be transparent. So, |
||
webpackConfig.enableAurelia(aureliaLoaderOptionsCallback); | ||
|
||
return this; | ||
}, | ||
|
||
/** | ||
* If enabled, display build notifications using | ||
* webpack-notifier. | ||
|
@@ -705,6 +717,12 @@ const publicApi = { | |
return this; | ||
}, | ||
|
||
configureResolveModules(directories) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this related to Aurelia? I mean, I know it's a webpack feature, but is it needed? I'm not familiar at all with Aurelia, so you'll have to help us out :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll give my best understanding, again, not super familiar with Webpack. This is something that's required for Aurelia. Aurelia uses dynamic module loading a fair bit, which means that Webpack doesn't understand how to resolve those dynamic modules. This option then tells Webpack to try resolving via a particular path. For example, my Webpack config code:
You can read more about it on the aurelia/webpack-plugin Wiki page. |
||
webpackConfig.configureResolveModules(directories); | ||
|
||
return this; | ||
}, | ||
|
||
/** | ||
* If enabled, the output directory is emptied between each build (to remove old files). | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ const stylusLoaderUtil = require('./loaders/stylus'); | |
const babelLoaderUtil = require('./loaders/babel'); | ||
const tsLoaderUtil = require('./loaders/typescript'); | ||
const vueLoaderUtil = require('./loaders/vue'); | ||
|
||
// plugins utils | ||
const extractTextPluginUtil = require('./plugins/extract-text'); | ||
const deleteUnusedEntriesPluginUtil = require('./plugins/delete-unused-entries'); | ||
|
@@ -33,6 +34,7 @@ const uglifyPluginUtil = require('./plugins/uglify'); | |
const friendlyErrorPluginUtil = require('./plugins/friendly-errors'); | ||
const assetOutputDisplay = require('./plugins/asset-output-display'); | ||
const notifierPluginUtil = require('./plugins/notifier'); | ||
const aureliaPluginUtil = require('./plugins/aurelia'); | ||
const PluginPriorities = require('./plugins/plugin-priorities'); | ||
|
||
class ConfigGenerator { | ||
|
@@ -89,6 +91,10 @@ class ConfigGenerator { | |
config.resolve.alias['react-dom'] = 'preact-compat'; | ||
} | ||
|
||
if (this.webpackConfig.resolveModules && Array.isArray(this.webpackConfig.resolveModules)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
config.resolve.modules = this.webpackConfig.resolveModules; | ||
} | ||
|
||
return config; | ||
} | ||
|
||
|
@@ -209,6 +215,12 @@ class ConfigGenerator { | |
}); | ||
} | ||
|
||
if (this.webpackConfig.useAurelia) { | ||
rules.push( | ||
{ test: /\.html$/i, use: 'html-loader' } | ||
); | ||
} | ||
|
||
this.webpackConfig.loaders.forEach((loader) => { | ||
rules.push(loader); | ||
}); | ||
|
@@ -243,6 +255,8 @@ class ConfigGenerator { | |
|
||
notifierPluginUtil(plugins, this.webpackConfig); | ||
|
||
aureliaPluginUtil(plugins, this.webpackConfig); | ||
|
||
if (!this.webpackConfig.runtimeConfig.outputJson) { | ||
const friendlyErrorPlugin = friendlyErrorPluginUtil(this.webpackConfig); | ||
plugins.push({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* This file is part of the Symfony Webpack Encore package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const PluginPriorities = require('./plugin-priorities'); | ||
const { AureliaPlugin } = require('aurelia-webpack-plugin'); | ||
|
||
/** | ||
* @param {Array} plugins | ||
* @param {WebpackConfig} webpackConfig | ||
* @return {void} | ||
*/ | ||
module.exports = function(plugins, webpackConfig) { | ||
if (!webpackConfig.useAurelia) return; | ||
|
||
plugins.push({ | ||
plugin: new AureliaPlugin(webpackConfig.aureliaPluginConfig), | ||
priority: PluginPriorities.AureliaPlugin | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,5 @@ module.exports = { | |
NamedModulesPlugin: 0, | ||
WebpackChunkHash: 0, | ||
WebpackNotifier: 0, | ||
AureliaPlugin: 0 | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,8 @@ | |
}, | ||
"homepage": "https://github.com/symfony/webpack-encore", | ||
"dependencies": { | ||
"aurelia-loader-webpack": "^2.1.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed? Is this a loader or a plugin? Also, these should be in |
||
"aurelia-webpack-plugin": "^2.0.0-rc.5", | ||
"babel-core": "^6.24.0", | ||
"babel-loader": "^7.1.0", | ||
"babel-preset-env": "^1.2.2", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a link to Aurelia here? And what are some valid callback options. We usually like to show an example :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)