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 |
|
14 | The `piral-instance-webpack-plugin` helps you to build Piral instances using Webpack.
|
15 |
|
16 | ## Getting Started
|
17 |
|
18 | To begin, you'll need to install `piral-instance-webpack-plugin`:
|
19 |
|
20 | ```sh
|
21 | npm install piral-instance-webpack-plugin --save-dev
|
22 | ```
|
23 |
|
24 | Then add the plugin to your `webpack` config. For example:
|
25 |
|
26 | **webpack.config.js**
|
27 |
|
28 | ```js
|
29 | const { PiralInstanceWebpackPlugin } = require('piral-instance-webpack-plugin');
|
30 | const piralPkg = require('./package.json');
|
31 |
|
32 | const excludedDependencies = ['piral', 'piral-core', 'piral-base', piralPkg.name];
|
33 | const dependencies = piralPkg.pilets?.externals ?? [];
|
34 | const externals = dependencies.filter((m) => !excludedDependencies.includes(m));
|
35 |
|
36 | module.exports = {
|
37 | plugins: [
|
38 | new PiralInstanceWebpackPlugin({
|
39 | name: piralPkg.name,
|
40 | version: piralPkg.version,
|
41 | externals,
|
42 | }),
|
43 | ],
|
44 | };
|
45 | ```
|
46 |
|
47 | And run `webpack` via your preferred method.
|
48 |
|
49 | ## Options
|
50 |
|
51 | ### `variables`
|
52 |
|
53 | Allows supplying additional variables to be used as definitions. Similar to the `definePlugin`.
|
54 |
|
55 | Example:
|
56 |
|
57 | ```js
|
58 | const { PiralInstanceWebpackPlugin } = require('piral-instance-webpack-plugin');
|
59 | const piralPkg = require('./package.json');
|
60 |
|
61 | const excludedDependencies = ['piral', 'piral-core', 'piral-base', piralPkg.name];
|
62 | const dependencies = piralPkg.pilets?.externals ?? [];
|
63 | const externals = dependencies.filter((m) => !excludedDependencies.includes(m));
|
64 |
|
65 | module.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 |
|
81 | Defines 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 |
|
83 | Example:
|
84 |
|
85 | ```js
|
86 | const { PiralInstanceWebpackPlugin } = require('piral-instance-webpack-plugin');
|
87 | const piralPkg = require('./package.json');
|
88 |
|
89 | const excludedDependencies = ['piral', 'piral-core', 'piral-base', piralPkg.name];
|
90 | const dependencies = piralPkg.pilets?.externals ?? [];
|
91 | const externals = dependencies.filter((m) => !excludedDependencies.includes(m));
|
92 |
|
93 | module.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 |
|
107 | Defines 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 |
|
109 | Example:
|
110 |
|
111 | ```js
|
112 | const { PiralInstanceWebpackPlugin } = require('piral-instance-webpack-plugin');
|
113 | const piralPkg = require('./package.json');
|
114 |
|
115 | const excludedDependencies = ['piral', 'piral-core', 'piral-base', piralPkg.name];
|
116 | const dependencies = piralPkg.pilets?.externals ?? [];
|
117 | const externals = dependencies.filter((m) => !excludedDependencies.includes(m));
|
118 |
|
119 | module.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 |
|
133 | Contributions in any form are appreciated and much welcome!
|
134 |
|
135 | Just 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 |
|
139 | This 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
|