Added build script
This commit is contained in:
parent
54d448d75d
commit
824672add0
@ -1,4 +1,6 @@
|
||||
{
|
||||
"name": "LiteRyzJS",
|
||||
"version": "0.1.0.154",
|
||||
"devDependencies": {
|
||||
"webpack": "^5.93.0",
|
||||
"webpack-cli": "^5.1.4"
|
||||
|
@ -1,4 +1,31 @@
|
||||
const path = require('path');
|
||||
const { version } = require('./package.json');
|
||||
const webpack = require('webpack');
|
||||
|
||||
|
||||
class PrependVersionPlugin {
|
||||
apply(compiler) {
|
||||
compiler.hooks.emit.tapAsync('PrependVersionPlugin', (compilation, callback) => {
|
||||
Object.keys(compilation.assets).forEach((filename) => {
|
||||
if (filename.endsWith('.js')) {
|
||||
const asset = compilation.assets[filename];
|
||||
|
||||
const headerText = `/*!\n * Part of LiteRyzJS v${version}\n * Copyright 2023-2024 Ray Lam (https://www.hiimray.co.uk)\n *\n */\n`;
|
||||
|
||||
const newContent = headerText + asset.source();
|
||||
|
||||
compilation.assets[filename] = {
|
||||
source: () => newContent,
|
||||
size: () => newContent.length,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
@ -7,11 +34,17 @@ module.exports = {
|
||||
project: './src/project.js'
|
||||
},
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
filename: `[name].min.js`,
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
library: 'LiteRyzJS', // The global variable name under which the classes will be exposed
|
||||
library: 'LiteRyzJS',
|
||||
libraryTarget: 'umd',
|
||||
globalObject: 'this'
|
||||
},
|
||||
mode: 'production', // development|production
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.VERSION': JSON.stringify(version)
|
||||
}),
|
||||
new PrependVersionPlugin()
|
||||
]
|
||||
};
|
Loading…
Reference in New Issue
Block a user