poops 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.yml +10 -0
- package/.github/dependabot.yml +9 -0
- package/.github/workflows/npm_publish.yml +17 -0
- package/LICENSE +21 -0
- package/README.md +301 -0
- package/dist/css/styles.css +17659 -0
- package/dist/css/styles.css.map +1 -0
- package/dist/css/styles.min.css +4 -0
- package/dist/js/scripts.js +35 -0
- package/dist/js/scripts.js.map +7 -0
- package/dist/js/scripts.min.js +2 -0
- package/index.html +86 -0
- package/package.json +44 -0
- package/poops.js +452 -0
- package/poops.json +35 -0
- package/src/js/main.ts +29 -0
- package/src/js/scripts/utils.ts +16 -0
- package/src/scss/index.scss +2 -0
- package/src/scss/style/index.scss +27 -0
- package/tsconfig.json +16 -0
package/.eslintrc.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
name: NPM Publish
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: [published]
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@v3
|
|
10
|
+
# Setup .npmrc file to publish to npm
|
|
11
|
+
- uses: actions/setup-node@v3
|
|
12
|
+
with:
|
|
13
|
+
node-version: '16.x'
|
|
14
|
+
- name: Publish to npm registry
|
|
15
|
+
run: |
|
|
16
|
+
echo "//registry.npmjs.org/:_authToken=\${{ secrets.NPM_TOKEN }}" >> .npmrc
|
|
17
|
+
npm publish
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Nikola Stamatović
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# 💩 Poops
|
|
2
|
+
> A super simple bundler for simple web projects.
|
|
3
|
+
|
|
4
|
+
----
|
|
5
|
+
|
|
6
|
+
Intuitive with a minimal learning curve and minimal docs, utilising the most efficient transpilers and compilers available (like [dart-sass](https://sass-lang.com/dart-sass) and [esbuild](https://esbuild.github.io/)) Poop aims to be the simplest bundler option there is. If it's not, please do contribute so we can make it so! 🙏 All ideas and contributions are welcome.
|
|
7
|
+
|
|
8
|
+
It uses a simple config file where you define your input and output paths and it poops out your bundled files. Simple as that.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
* Bundles SCSS/SASS to CSS
|
|
13
|
+
* Uses [dart-sass](https://sass-lang.com/dart-sass) for SCSS/SASS bundling
|
|
14
|
+
* CSS minification with Nanocss and Autoprefixer via [postcss](https://postcss.org/)
|
|
15
|
+
* Bundles JS/TS to IIFE/ESM/CJS
|
|
16
|
+
* Uses [esbuild](https://esbuild.github.io/) for ES bundling
|
|
17
|
+
* Uses [terser](https://terser.org/) for JS minification and mangling
|
|
18
|
+
* Supports multiple input and output paths
|
|
19
|
+
* Resolves node modules
|
|
20
|
+
* Can add a templatable banner to output files (optional)
|
|
21
|
+
* Supports source maps (optional)
|
|
22
|
+
* Supports minification (optional)
|
|
23
|
+
* Has a configurable local server (optional)
|
|
24
|
+
* Rebuilds on file changes (optional)
|
|
25
|
+
* Live reloads on file changes (optional)
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
You can install Poops globally:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm i -g poops
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
or locally:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm i -D poops
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
If you have installed Poops globally, create a `poops.json` configuration file in the project root (see [Configuration](#configuration) on how to configure) and run:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
s
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
or pass a custom config. This is usefull when you have multiple environments:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
poops yourAwesomeConfig.json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If you have installed Poop locally you can run it with `npx poops` or add a script to your `package.json`:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "npx poops"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
Configuring Poops is simple 😌. Let's presume that we have a `src/scss` and `src/js` directories and we want to bundle the files into `dist/css` and `dist/js`.
|
|
65
|
+
|
|
66
|
+
Just create a `poops.json` file in the root of your project and add the following (you can see this sample config in this repo's root):
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"scripts": [{
|
|
71
|
+
"in": "src/js/main.ts",
|
|
72
|
+
"out": "dist/js/scripts.js",
|
|
73
|
+
"options": {
|
|
74
|
+
"sourcemap": true,
|
|
75
|
+
"minify": true,
|
|
76
|
+
"justMinified": false,
|
|
77
|
+
"format": "iife",
|
|
78
|
+
"target": "es2019",
|
|
79
|
+
"mangle": true
|
|
80
|
+
}
|
|
81
|
+
}],
|
|
82
|
+
"styles": [{
|
|
83
|
+
"in": "src/scss/index.scss",
|
|
84
|
+
"out": "dist/css/styles.css",
|
|
85
|
+
"options": {
|
|
86
|
+
"sourcemap": true,
|
|
87
|
+
"minify": true,
|
|
88
|
+
"justMinified": false
|
|
89
|
+
}
|
|
90
|
+
}],
|
|
91
|
+
"banner": "/* {{ name }} v{{ version }} | {{ homepage }} | {{ license }} License */",
|
|
92
|
+
"serve" : {
|
|
93
|
+
"port": 4040,
|
|
94
|
+
"base": "/"
|
|
95
|
+
},
|
|
96
|
+
"livereload": true,
|
|
97
|
+
"watch": [
|
|
98
|
+
"src"
|
|
99
|
+
],
|
|
100
|
+
"includePaths": [
|
|
101
|
+
"node_modules"
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
All config properties are optional except `scripts` or `styles`. You have to specify at least one of them. If you don't have anything to consume, you won't poop. 💩
|
|
107
|
+
|
|
108
|
+
You can freely remove the properies that you don't need. For example, if you don't want to run a local server, just remove the `serve` property from the config.
|
|
109
|
+
|
|
110
|
+
### Scripts
|
|
111
|
+
|
|
112
|
+
Scripts are bundled with [esbuild](https://esbuild.github.io/). You can specify multiple scripts to bundle. Each script has the following properties:
|
|
113
|
+
|
|
114
|
+
* `in` - the input path, can be an array of file paths, but please just use one file path per script
|
|
115
|
+
* `out` - the output path, can be a directory or a file path, but please just use it as a filename
|
|
116
|
+
* `options` - the options for the bundler. You can apply most of the esbuild options that are not in conflict with Poops. See [esbuild's options](https://esbuild.github.io/api/#build-api) for more info.
|
|
117
|
+
|
|
118
|
+
Options:
|
|
119
|
+
* `sourcemap` - whether to generate sourcemaps or not, sourcemaps are generated only for non-minified files since they are useful for debugging. Default is `false`
|
|
120
|
+
* `minify` - whether to minify the output or not, minification is performed by Terser and is only applied to non-minified files. Default is `false`
|
|
121
|
+
* `mangle` - whether to mangle the output or not, mangling is performed by Terser and this is the only Terser oprion. Default is `false`
|
|
122
|
+
* `justMinified` - whether you want to have a minified file as output only. Removes the non-minified file from the output. Useful for production builds. Default is `false`
|
|
123
|
+
* `format` - the output format, can be `iife` or `esm` or `cjs` - this is a direct esbuild option
|
|
124
|
+
* `target` - the target for the output, can be `es2018` or `es2019` or `es2020` or `esnext` for instance - this is a direct esbuild option
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
`scripts` property can accept an array of script configurations or just a single script configuration. If you want to bundle multiple scripts, just add them to the `scripts` array:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"scripts": [
|
|
132
|
+
{
|
|
133
|
+
"in": "src/js/main.ts",
|
|
134
|
+
"out": "dist/js/scripts.js",
|
|
135
|
+
"options": {
|
|
136
|
+
"sourcemap": true,
|
|
137
|
+
"minify": true,
|
|
138
|
+
"justMinified": false,
|
|
139
|
+
"format": "iife",
|
|
140
|
+
"target": "es2019",
|
|
141
|
+
"mangle": true
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"in": "src/js/other.ts",
|
|
146
|
+
"out": "dist/js/other.js",
|
|
147
|
+
"options": {
|
|
148
|
+
"sourcemap": true,
|
|
149
|
+
"minify": true,
|
|
150
|
+
"justMinified": false,
|
|
151
|
+
"format": "iife",
|
|
152
|
+
"target": "es2019",
|
|
153
|
+
"mangle": true
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
As noted earlier, if you don't want to bundle scripts, just remove the `scripts` property from the config.
|
|
161
|
+
|
|
162
|
+
### Styles
|
|
163
|
+
|
|
164
|
+
Styles are bundled with [Dart Sass](https://sass-lang.com/dart-sass). You can specify multiple styles to bundle. Each style has the following properties:
|
|
165
|
+
|
|
166
|
+
* `in` - the input path, accepts only a path to a file
|
|
167
|
+
* `out` - the output path, can be a directory or a file path, but please just use it as a filename
|
|
168
|
+
* `options` - the options for the bundler.
|
|
169
|
+
|
|
170
|
+
Options:
|
|
171
|
+
* `sourcemap` - whether to generate sourcemaps or not, sourcemaps are generated only for non-minified files since they are useful for debugging. Default is `false`
|
|
172
|
+
* `minify` - whether to minify the output or not, minification is performed by `cssnano` and is only applied to non-minified files. At the minification step, `autoprefixer` is also applied. Default is `false`
|
|
173
|
+
* `justMinified` - whether you want to have a minified file as output only. Removes the non-minified file from the output. Useful for production builds. Defaults to `false`.
|
|
174
|
+
|
|
175
|
+
`styles` property can accept an array of style configurations or just a single style configuration. If you want to bundle multiple styles, just add them to the `styles` array:
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"styles": [
|
|
180
|
+
{
|
|
181
|
+
"in": "src/scss/main.scss",
|
|
182
|
+
"out": "dist/css/styles.css",
|
|
183
|
+
"options": {
|
|
184
|
+
"sourcemap": true,
|
|
185
|
+
"minify": true,
|
|
186
|
+
"justMinified": false
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"in": "src/scss/other.scss",
|
|
191
|
+
"out": "dist/css/other.css",
|
|
192
|
+
"options": {
|
|
193
|
+
"sourcemap": true,
|
|
194
|
+
"minify": true,
|
|
195
|
+
"justMinified": false
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
As noted earlier, if you don't want to bundle styles, just remove the `styles` property from the config.
|
|
203
|
+
|
|
204
|
+
### Banner (optional)
|
|
205
|
+
|
|
206
|
+
Here you can specify a banner that will be added to the top of the output files. It is templatable via mustache. The following variables are available from your project's `package.json`:
|
|
207
|
+
|
|
208
|
+
* `name`
|
|
209
|
+
* `version`
|
|
210
|
+
* `homepage`
|
|
211
|
+
* `license`
|
|
212
|
+
* `author`
|
|
213
|
+
* `description`
|
|
214
|
+
|
|
215
|
+
If you don't want to add a banner, just remove the `banner` property from the config.
|
|
216
|
+
|
|
217
|
+
### Local Server (optional)
|
|
218
|
+
Sets up a local server for your project.
|
|
219
|
+
|
|
220
|
+
Server options:
|
|
221
|
+
* `port` - the port on which the server will run
|
|
222
|
+
* `base` - the base path of the server, where your HTML files are located
|
|
223
|
+
|
|
224
|
+
If you don't want to run a local server, just remove the `serve` property from the config.
|
|
225
|
+
|
|
226
|
+
### Live Reload (optional)
|
|
227
|
+
Sets up a livereload server for your project.
|
|
228
|
+
|
|
229
|
+
Live reload options:
|
|
230
|
+
* `port` - the port on which the livereload server will run
|
|
231
|
+
* `exclude` - an array of files and directories to exclude from livereload
|
|
232
|
+
|
|
233
|
+
`livereload` can only be `true`, which means that it will run on the default port (`35729`) or you can specify a port:
|
|
234
|
+
|
|
235
|
+
```json
|
|
236
|
+
{
|
|
237
|
+
"livereload": {
|
|
238
|
+
"port": whateverPortYouWant
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
You can also exclude files and directories from livereload:
|
|
244
|
+
|
|
245
|
+
```json
|
|
246
|
+
{
|
|
247
|
+
"livereload": {
|
|
248
|
+
"exclude": [
|
|
249
|
+
"some_directory/**/*",
|
|
250
|
+
"some_other_directory/**/*"
|
|
251
|
+
]
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
If you don't want to run livereload, just remove the `livereload` property from the config, or set it to false.
|
|
257
|
+
|
|
258
|
+
### Watch (optional)
|
|
259
|
+
Sets up a watcher for your project which will rebuild your files on change.
|
|
260
|
+
|
|
261
|
+
`watch` propery accepts an array of paths to watch for changes. If you want to watch for changes in the `src` directory, just add it to the `watch` array:
|
|
262
|
+
|
|
263
|
+
```json
|
|
264
|
+
{
|
|
265
|
+
"watch": [
|
|
266
|
+
"src"
|
|
267
|
+
]
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
If you don't want to watch for file changes, just remove the `watch` property from the config.
|
|
272
|
+
|
|
273
|
+
### Include Paths (optional)
|
|
274
|
+
This property is used to specify paths that you want to resolve your imports from. Like `node_modules`. You don't need to specify the `includePaths`, `node_modules` are included by default. But if you do specify `includePaths`, you need to include `node_modules` as well, since this change will override the default behaviour.
|
|
275
|
+
|
|
276
|
+
Same as `watch` property, `includePaths` accepts an array of paths to include. If you want to include `src` directory, just add it to the `includePaths` array:
|
|
277
|
+
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"includePaths": [
|
|
281
|
+
"src"
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Todo
|
|
287
|
+
|
|
288
|
+
* [ ] Run esbuild for each input path individually if there are multiple input paths
|
|
289
|
+
* [ ] Styles `in` should be able to support array of inputs like we have it on scripts
|
|
290
|
+
* [ ] Add more argv options like config creation, etc.
|
|
291
|
+
* [ ] Add nunjucs or liquid static templating
|
|
292
|
+
|
|
293
|
+
## Why?
|
|
294
|
+
|
|
295
|
+
Why doesn't anyone maintain GULP anymore? Why does Parcel hate config files? Why are Rollup and Webpack so complex to setup for simple tasks? Vite???? What's going on?
|
|
296
|
+
|
|
297
|
+
I'm tired... Tired of bullshit... I just want to bundle my scss/sass and/or my js/ts to css and iife/esm js, by providing input and output paths for both/one. And to be able to have minimal easily maintainable dependancies. I don't need plugins, I'll add the features manually for the practice I use. That's it. The f**king end.
|
|
298
|
+
|
|
299
|
+
This is a bundler written by me for myself and those like me. Hopefully it's helpful to you too.
|
|
300
|
+
|
|
301
|
+
Love :heart: and peace :v:.
|