Browse Source

Composer update recipes symfony/webpack-encore-bundle

pull/5/head
ScytAl3 5 months ago
parent
commit
53e54667dd
  1. 1
      .gitignore
  2. 12
      assets/app.js
  3. 11
      assets/bootstrap.js
  4. 4
      assets/controllers.json
  5. 16
      assets/controllers/hello_controller.js
  6. 3
      assets/styles/app.css
  7. 11
      config/packages/webpack_encore.yaml
  8. 4
      package.json
  9. 13
      symfony.lock
  10. 23
      webpack.config.js

1
.gitignore

@ -60,6 +60,7 @@
###> symfony/webpack-encore-bundle ###
/node_modules/
/public/build/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###

12
assets/app.js

@ -0,0 +1,12 @@
/*
* Welcome to your app's main JavaScript file!
*
* We recommend including the built version of this JavaScript file
* (and its CSS file) in your base layout (base.html.twig).
*/
// any CSS you import will output into a single css file (app.css in this case)
import './styles/app.css';
// start the Stimulus application
import './bootstrap';

11
assets/bootstrap.js

@ -0,0 +1,11 @@
import { startStimulusApp } from '@symfony/stimulus-bridge';
// Registers Stimulus controllers from controllers.json and in the controllers/ directory
export const app = startStimulusApp(require.context(
'@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
true,
/\.(j|t)sx?$/
));
// register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController);

4
assets/controllers.json

@ -0,0 +1,4 @@
{
"controllers": [],
"entrypoints": []
}

16
assets/controllers/hello_controller.js

@ -0,0 +1,16 @@
import { Controller } from 'stimulus';
/*
* This is an example Stimulus controller!
*
* Any element with a data-controller="hello" attribute will cause
* this controller to be executed. The name "hello" comes from the filename:
* hello_controller.js -> "hello"
*
* Delete this file or adapt it for your use!
*/
export default class extends Controller {
connect() {
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
}
}

3
assets/styles/app.css

@ -0,0 +1,3 @@
body {
background-color: lightgray;
}

11
config/packages/webpack_encore.yaml

@ -4,16 +4,21 @@ webpack_encore:
# If multiple builds are defined (as shown below), you can disable the default build:
# output_path: false
# if using Encore.enableIntegrityHashes() and need the crossorigin attribute (default: false, or use 'anonymous' or 'use-credentials')
# Set attributes that will be rendered on all script and link tags
script_attributes:
defer: true
# link_attributes:
# If using Encore.enableIntegrityHashes() and need the crossorigin attribute (default: false, or use 'anonymous' or 'use-credentials')
# crossorigin: 'anonymous'
# preload all rendered script and link tags automatically via the http2 Link header
# Preload all rendered script and link tags automatically via the HTTP/2 Link header
# preload: true
# Throw an exception if the entrypoints.json file is missing or an entry is missing from the data
# strict_mode: false
# if you have multiple builds:
# If you have multiple builds:
# builds:
# pass "frontend" as the 3rg arg to the Twig functions
# {{ encore_entry_script_tags('entry1', null, 'frontend') }}

4
package.json

@ -1,6 +1,7 @@
{
"devDependencies": {
"@symfony/webpack-encore": "^0.31.0",
"@symfony/stimulus-bridge": "^2.0.0",
"@symfony/webpack-encore": "^1.0.0",
"bootstrap": "^4.5.3",
"copy-webpack-plugin": "^6.2.1",
"core-js": "^3.0.0",
@ -9,6 +10,7 @@
"popper.js": "^1.16.1",
"regenerator-runtime": "^0.13.2",
"sass-loader": "8.0.0",
"stimulus": "^2.0.0",
"webpack-notifier": "^1.6.0"
},
"license": "UNLICENSED",

13
symfony.lock

@ -540,16 +540,19 @@
]
},
"symfony/webpack-encore-bundle": {
"version": "1.6",
"version": "1.9",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.6",
"ref": "69e1d805ad95964088bd510c05995e87dc391564"
"version": "1.9",
"ref": "9399a0bfc6ee7a0c019f952bca46d6a6045dd451"
},
"files": [
"./assets/css/app.css",
"./assets/js/app.js",
"./assets/app.js",
"./assets/bootstrap.js",
"./assets/controllers.json",
"./assets/controllers/hello_controller.js",
"./assets/styles/app.css",
"./config/packages/assets.yaml",
"./config/packages/prod/webpack_encore.yaml",
"./config/packages/test/webpack_encore.yaml",

23
webpack.config.js

@ -1,4 +1,4 @@
var Encore = require('@symfony/webpack-encore');
const Encore = require('@symfony/webpack-encore');
// add the the copy-webpack-plugin
const CopyPlugin = require('copy-webpack-plugin');
@ -32,16 +32,14 @@ Encore
/*
* ENTRY CONFIG
*
* Add 1 entry for each "page" of your app
* (including one that's included on every page - e.g. "app")
*
* Each entry will result in one JavaScript file (e.g. app.js)
* and one CSS file (e.g. app.css) if your JavaScript imports CSS.
*/
.addEntry('app', './assets/js/app.js')
.addEntry('pdf', './assets/js/pdf.js')
//.addEntry('page1', './assets/js/page1.js')
//.addEntry('page2', './assets/js/page2.js')
// enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
.enableStimulusBridge('./assets/controllers.json')
// When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
.splitEntryChunks()
@ -63,6 +61,10 @@ Encore
// enables hashed filenames (e.g. app.abc123.css)
.enableVersioning(Encore.isProduction())
.configureBabel((config) => {
config.plugins.push('@babel/plugin-proposal-class-properties');
})
// enables @babel/preset-env polyfills
.configureBabelPresetEnv((config) => {
config.useBuiltIns = 'usage';
@ -75,16 +77,15 @@ Encore
// uncomment if you use TypeScript
//.enableTypeScriptLoader()
// uncomment if you use React
//.enableReactPreset()
// uncomment to get integrity="..." attributes on your script & link tags
// requires WebpackEncoreBundle 1.4 or higher
//.enableIntegrityHashes(Encore.isProduction())
// uncomment if you're having problems with a jQuery plugin
//.autoProvidejQuery()
// uncomment if you use API Platform Admin (composer req api-admin)
//.enableReactPreset()
//.addEntry('admin', './assets/js/admin.js')
;
;
module.exports = Encore.getWebpackConfig();

Loading…
Cancel
Save