updated to webpack 4
This commit is contained in:
parent
b76899a353
commit
ebf6bda467
17 changed files with 6052 additions and 5223 deletions
|
@ -17,7 +17,7 @@ function merge(m1, m2) {
|
|||
}
|
||||
|
||||
module.exports = function(source) {
|
||||
const localeExp = this.options.locale || /([^/]+)\/[^/]+\.ftl$/;
|
||||
const localeExp = /([^/]+)\/[^/]+\.ftl$/;
|
||||
const result = localeExp.exec(this.resourcePath);
|
||||
const locale = result && result[1];
|
||||
if (!locale) {
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
const commit = require('git-rev-sync').short();
|
||||
|
||||
module.exports = function(source) {
|
||||
const pkg = JSON.parse(source);
|
||||
const version = {
|
||||
commit,
|
||||
source: pkg.homepage,
|
||||
version: process.env.CIRCLE_TAG || `v${pkg.version}`
|
||||
};
|
||||
return `module.exports = '${JSON.stringify(version)}'`;
|
||||
};
|
|
@ -12,13 +12,9 @@ This loader enumerates all the files in `assets/` so that `common/assets.js` can
|
|||
|
||||
This loader enumerates all the ftl files in `public/locales` so that the fluent loader can create it's js files.
|
||||
|
||||
## Package.json Loader
|
||||
## Version Plugin
|
||||
|
||||
This loader creates a `version.json` file that gets exposed by the `/__version__` route from the `package.json` file and current git commit hash.
|
||||
|
||||
## Version Loader
|
||||
|
||||
This loader substitutes the string "VERSION" for the version string specified in `package.json`. This is a workaround because `package.json` already uses the `package_json_loader`. See [app/templates/header/index.js](../app/templates/header/index.js) for more info.
|
||||
Creates a `version.json` file that gets exposed by the `/__version__` route from the `package.json` file and current git commit hash.
|
||||
|
||||
# See Also
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
const version = require('../package.json').version;
|
||||
|
||||
module.exports = function(source) {
|
||||
return source.replace('VERSION', version);
|
||||
};
|
25
build/version_plugin.js
Normal file
25
build/version_plugin.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
const commit = require('git-rev-sync').short();
|
||||
const pkg = require('../package.json');
|
||||
|
||||
const version = JSON.stringify({
|
||||
commit,
|
||||
source: pkg.homepage,
|
||||
version: process.env.CIRCLE_TAG || `v${pkg.version}`
|
||||
});
|
||||
|
||||
class VersionPlugin {
|
||||
apply(compiler) {
|
||||
compiler.hooks.emit.tap('VersionPlugin', compilation => {
|
||||
compilation.assets['version.json'] = {
|
||||
source() {
|
||||
return version;
|
||||
},
|
||||
size() {
|
||||
return version.length
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = VersionPlugin;
|
Loading…
Add table
Add a link
Reference in a new issue