UNPKG

4.28 kBMarkdownView Raw
1<div align="center">
2 <a href="https://github.com/webpack/webpack">
3 <img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
4 </a>
5</div>
6
7[![npm][npm]][npm-url]
8[![node][node]][node-url]
9[![chat][chat]][chat-url]
10[![size][size]][size-url]
11
12# piral-instance-webpack-plugin
13
14The `piral-instance-webpack-plugin` helps you to build Piral instances using Webpack.
15
16## Getting Started
17
18To begin, you'll need to install `piral-instance-webpack-plugin`:
19
20```sh
21npm install piral-instance-webpack-plugin --save-dev
22```
23
24Then add the plugin to your `webpack` config. For example:
25
26**webpack.config.js**
27
28```js
29const { PiralInstanceWebpackPlugin } = require('piral-instance-webpack-plugin');
30const piralPkg = require('./package.json');
31
32const excludedDependencies = ['piral', 'piral-core', 'piral-base', piralPkg.name];
33const dependencies = piralPkg.pilets?.externals ?? [];
34const externals = dependencies.filter((m) => !excludedDependencies.includes(m));
35
36module.exports = {
37 plugins: [
38 new PiralInstanceWebpackPlugin({
39 name: piralPkg.name,
40 version: piralPkg.version,
41 externals,
42 }),
43 ],
44};
45```
46
47And run `webpack` via your preferred method.
48
49## Options
50
51### `variables`
52
53Allows supplying additional variables to be used as definitions. Similar to the `definePlugin`.
54
55Example:
56
57```js
58const { PiralInstanceWebpackPlugin } = require('piral-instance-webpack-plugin');
59const piralPkg = require('./package.json');
60
61const excludedDependencies = ['piral', 'piral-core', 'piral-base', piralPkg.name];
62const dependencies = piralPkg.pilets?.externals ?? [];
63const externals = dependencies.filter((m) => !excludedDependencies.includes(m));
64
65module.exports = {
66 plugins: [
67 new PiralInstanceWebpackPlugin({
68 name: piralPkg.name,
69 version: piralPkg.version,
70 externals,
71 variables: {
72 PIRAL_CLI_VERSION: require('piral-cli/package.json').version,
73 },
74 }),
75 ],
76};
77```
78
79### `debug`
80
81Defines the version of the general debugging tools, if any. Setting `true` will auto-determine the version. Setting `false` or omitting will not include general debugging tools.
82
83Example:
84
85```js
86const { PiralInstanceWebpackPlugin } = require('piral-instance-webpack-plugin');
87const piralPkg = require('./package.json');
88
89const excludedDependencies = ['piral', 'piral-core', 'piral-base', piralPkg.name];
90const dependencies = piralPkg.pilets?.externals ?? [];
91const externals = dependencies.filter((m) => !excludedDependencies.includes(m));
92
93module.exports = {
94 plugins: [
95 new PiralInstanceWebpackPlugin({
96 name: piralPkg.name,
97 version: piralPkg.version,
98 externals,
99 debug: true,
100 }),
101 ],
102};
103```
104
105### `emulator`
106
107Defines the path of the emulator pilet API, if any. Setting `true` will take the default path. Setting `false` or omitting will not include the emulator pilet API call.
108
109Example:
110
111```js
112const { PiralInstanceWebpackPlugin } = require('piral-instance-webpack-plugin');
113const piralPkg = require('./package.json');
114
115const excludedDependencies = ['piral', 'piral-core', 'piral-base', piralPkg.name];
116const dependencies = piralPkg.pilets?.externals ?? [];
117const externals = dependencies.filter((m) => !excludedDependencies.includes(m));
118
119module.exports = {
120 plugins: [
121 new PiralInstanceWebpackPlugin({
122 name: piralPkg.name,
123 version: piralPkg.version,
124 externals,
125 emulator: '/$pilet-api',
126 }),
127 ],
128};
129```
130
131## Contributing
132
133Contributions in any form are appreciated and much welcome!
134
135Just make sure to post an issue or reach out to me on [Gitter](https://gitter.im/piral-io/community) before starting actual work on anything. It really helps to avoid problems.
136
137## License
138
139This plugin is released using the MIT license.
140
141[npm]: https://img.shields.io/npm/v/piral-instance-webpack-plugin.svg
142[npm-url]: https://npmjs.com/package/piral-instance-webpack-plugin
143[node]: https://img.shields.io/node/v/piral-instance-webpack-plugin.svg
144[node-url]: https://nodejs.org
145[chat]: https://img.shields.io/badge/gitter-piral.io%2Fcommunity-brightgreen.svg
146[chat-url]: https://gitter.im/piral-io/community
147[size]: https://packagephobia.now.sh/badge?p=piral-instance-webpack-plugin
148[size-url]: https://packagephobia.now.sh/result?p=piral-instance-webpack-plugin