-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ESbuild via JS Bundling gem (#18)
* Setup Hotwire and NPM package * fix install generator * Setup ESlint
- Loading branch information
1 parent
e8d7187
commit 61ee3e7
Showing
17 changed files
with
1,096 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
**/vendor/** | ||
**/dummy/** | ||
**/sandbox/** | ||
*-min.js | ||
*.min.js | ||
jquery*.js | ||
/cli/lib/spree_cli/templates/** | ||
app/assets/javascripts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module.exports = { | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"ecmaVersion": 13, | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"indent": [ | ||
"error", | ||
2 | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"unix" | ||
], | ||
"quotes": [ | ||
"error", | ||
"double" | ||
], | ||
"semi": [ | ||
"error", | ||
"never" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Application } from "@hotwired/stimulus" | ||
|
||
const application = Application.start() | ||
|
||
// Configure Stimulus development experience | ||
application.debug = false | ||
window.Stimulus = application | ||
|
||
export { application } |
10 changes: 10 additions & 0 deletions
10
app/javascript/spree/dashboard/controllers/hello_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
export default class extends Controller { | ||
static targets = [ "name", "output" ] | ||
|
||
greet() { | ||
this.outputTarget.textContent = | ||
`Hello, ${this.nameTarget.value}!` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// This file is auto-generated by ./bin/rails stimulus:manifest:update | ||
// Run that command whenever you add a new controller | ||
|
||
import { application } from "./application" | ||
|
||
import HelloController from "./hello_controller" | ||
application.register("hello", HelloController) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import "./controllers" | ||
// import * as Turbo from "@hotwired/turbo" | ||
|
||
class Dashboard { | ||
constructor() { | ||
console.log("Spree Dashboard initialized") | ||
} | ||
} | ||
|
||
export { | ||
Dashboard | ||
// Turbo | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
lib/generators/spree/backend/install/templates/app/javascript/spree-dashboard.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Entry point for the build script in your package.json | ||
|
||
import "@spree/dashboard" | ||
|
||
new SpreeDashboard.Dashboard() | ||
|
||
// window.Turbo = SpreeDashboard.Turbo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "@spree/dashboard", | ||
"version": "0.0.1-alpha1", | ||
"description": "Spree Dashboard", | ||
"main": "app/assets/javascripts/spree_dashboard.js", | ||
"type": "module", | ||
"files": [ | ||
"app/assets/javascripts/*.js", | ||
"src/*.js" | ||
], | ||
"homepage": "https://spreecommerce.org/", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/spree/spree_backend.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/spree/spree_backend/issues" | ||
}, | ||
"author": "Spark Solutions <hi@sparksolutions.co>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@hotwired/stimulus": "^3.0.1", | ||
"@hotwired/turbo": "^7.0.1" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^19.0.1", | ||
"@rollup/plugin-node-resolve": "^11.0.1", | ||
"eslint": "^8.2.0", | ||
"rollup": "^2.35.1", | ||
"rollup-plugin-terser": "^7.0.2" | ||
}, | ||
"scripts": { | ||
"build": "rollup --config rollup.config.js", | ||
"watch": "rollup --config rollup.config.js -w", | ||
"lint": "eslint app/javascript", | ||
"prepublishOnly": "rm -rf src && cp -R app/javascript/spree_dashboard src" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import resolve from "@rollup/plugin-node-resolve" | ||
import commonjs from "@rollup/plugin-commonjs" | ||
import { terser } from "rollup-plugin-terser" | ||
|
||
const terserOptions = { | ||
mangle: false, | ||
compress: false, | ||
format: { | ||
beautify: true, | ||
indent_level: 2 | ||
} | ||
} | ||
|
||
export default [ | ||
{ | ||
input: "app/javascript/spree/dashboard/index.js", | ||
output: { | ||
file: "app/assets/javascripts/spree_dashboard.js", | ||
format: "umd", | ||
name: "SpreeDashboard" | ||
}, | ||
plugins: [ | ||
resolve(), | ||
commonjs(), | ||
terser(terserOptions) | ||
] | ||
}, | ||
|
||
{ | ||
input: "app/javascript/spree/dashboard/index.js", | ||
output: { | ||
file: "app/assets/javascripts/spree_dashboard.esm.js", | ||
format: "es" | ||
}, | ||
plugins: [ | ||
resolve(), | ||
commonjs(), | ||
terser(terserOptions) | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.