Skip to content

Commit c537cc1

Browse files
committed
first commit
1 parent 6df3af4 commit c537cc1

File tree

8 files changed

+93
-0
lines changed

8 files changed

+93
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules/

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
# alpinejs-plugin-blueprint
2+
3+
Replace all `plugin` and `magic` text to your corresponding code

builds/cdn.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import plugin from '../src/index.js'
2+
3+
document.addEventListener('alpine:init', () => {
4+
window.Alpine.plugin(plugin)
5+
})

builds/module.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import plugin from '../src/index.js'
2+
3+
export default plugin

package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "@victoryoalli/alpinejs-plugin-blueprint",
3+
"version": "1.0.0",
4+
"description": "Super alpine.js plugin",
5+
"main": "dist/plugin.cjs.js",
6+
"module": "dist/plugin.esm.js",
7+
"unpkg": "dist/plugin.min.js",
8+
"keywords": [],
9+
"author": "Victor Yoalli",
10+
"license": "MIT",
11+
"dependencies": {
12+
"esbuild": "^0.12.22"
13+
},
14+
"scripts": {
15+
"build": "node scripts/build.js"
16+
}
17+
}

scripts/build.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
let fs = require('fs')
2+
//CDN
3+
build({
4+
entryPoints: [`builds/cdn.js`],
5+
outfile: `dist/plugin.min.js`,
6+
bundle: true,
7+
minify: true,
8+
sourcemap: false,
9+
platform: 'browser',
10+
define: { CDN: true },
11+
})
12+
//Module
13+
build({
14+
entryPoints: [`builds/module.js`],
15+
outfile: `dist/plugin.esm.js`,
16+
bundle: true,
17+
bundle: true,
18+
platform: 'neutral',
19+
mainFields: ['main', 'module'],
20+
})
21+
build({
22+
entryPoints: [`builds/module.js`],
23+
outfile: `dist/plugin.cjs.js`,
24+
bundle: true,
25+
target: ['node10.4'],
26+
platform: 'node',
27+
})
28+
29+
30+
function build(options){
31+
options.define || (options.define = {})
32+
options.define['process.env.NODE_ENV'] = process.argv.includes('--watch') ? `'production'` : `'development'`
33+
34+
return require('esbuild').build({
35+
watch: process.argv.includes('--watch'),
36+
// external: ['alpinejs'],
37+
...options,
38+
}).catch(() => process.exit(1))
39+
}

src/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const Plugin = function (Alpine) {
2+
Alpine.directive('plugin', (el, obj, { evaluateLater, effect, cleanup }) => {
3+
let { value, expression, modifiers } = obj;
4+
let evaluate = evaluateLater(expression);
5+
6+
cleanup(() => observer.disconnect())
7+
})
8+
Alpine.magic('magic',() => { return 'magic' })
9+
}
10+
11+
export default Plugin

0 commit comments

Comments
 (0)