Skip to content

Commit 8186150

Browse files
Remove instruction to "uncomment" in webpack-encore-bundle recipe (#1062)
1 parent 615cc3c commit 8186150

File tree

10 files changed

+212
-0
lines changed

10 files changed

+212
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Welcome to your app's main JavaScript file!
3+
*
4+
* We recommend including the built version of this JavaScript file
5+
* (and its CSS file) in your base layout (base.html.twig).
6+
*/
7+
8+
// any CSS you import will output into a single css file (app.css in this case)
9+
import './styles/app.css';
10+
11+
// start the Stimulus application
12+
import './bootstrap';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { startStimulusApp } from '@symfony/stimulus-bridge';
2+
3+
// Registers Stimulus controllers from controllers.json and in the controllers/ directory
4+
export const app = startStimulusApp(require.context(
5+
'@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
6+
true,
7+
/\.(j|t)sx?$/
8+
));
9+
10+
// register any custom, 3rd party controllers here
11+
// app.register('some_controller_name', SomeImportedController);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"controllers": [],
3+
"entrypoints": []
4+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Controller } from '@hotwired/stimulus';
2+
3+
/*
4+
* This is an example Stimulus controller!
5+
*
6+
* Any element with a data-controller="hello" attribute will cause
7+
* this controller to be executed. The name "hello" comes from the filename:
8+
* hello_controller.js -> "hello"
9+
*
10+
* Delete this file or adapt it for your use!
11+
*/
12+
export default class extends Controller {
13+
connect() {
14+
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
15+
}
16+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
background-color: lightgray;
3+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
webpack_encore:
2+
# The path where Encore is building the assets - i.e. Encore.setOutputPath()
3+
output_path: '%kernel.project_dir%/public/build'
4+
# If multiple builds are defined (as shown below), you can disable the default build:
5+
# output_path: false
6+
7+
# Set attributes that will be rendered on all script and link tags
8+
script_attributes:
9+
defer: true
10+
# Uncomment (also under link_attributes) if using Turbo Drive
11+
# https://turbo.hotwired.dev/handbook/drive#reloading-when-assets-change
12+
# 'data-turbo-track': reload
13+
# link_attributes:
14+
# Uncomment if using Turbo Drive
15+
# 'data-turbo-track': reload
16+
17+
# If using Encore.enableIntegrityHashes() and need the crossorigin attribute (default: false, or use 'anonymous' or 'use-credentials')
18+
# crossorigin: 'anonymous'
19+
20+
# Preload all rendered script and link tags automatically via the HTTP/2 Link header
21+
# preload: true
22+
23+
# Throw an exception if the entrypoints.json file is missing or an entry is missing from the data
24+
# strict_mode: false
25+
26+
# If you have multiple builds:
27+
# builds:
28+
# pass "frontend" as the 3rg arg to the Twig functions
29+
# {{ encore_entry_script_tags('entry1', null, 'frontend') }}
30+
31+
# frontend: '%kernel.project_dir%/public/frontend/build'
32+
33+
# Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)
34+
# Put in config/packages/prod/webpack_encore.yaml
35+
# cache: true
36+
37+
framework:
38+
assets:
39+
json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'
40+
41+
#when@prod:
42+
# webpack_encore:
43+
# # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)
44+
# # Available in version 1.2
45+
# cache: true
46+
47+
#when@test:
48+
# webpack_encore:
49+
# strict_mode: false
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"bundles": {
3+
"Symfony\\WebpackEncoreBundle\\WebpackEncoreBundle": ["all"]
4+
},
5+
"copy-from-recipe": {
6+
"assets/": "assets/",
7+
"config/": "%CONFIG_DIR%/",
8+
"package.json": "package.json",
9+
"webpack.config.js": "webpack.config.js"
10+
},
11+
"aliases": ["ux", "encore", "webpack", "webpack-encore"],
12+
"gitignore": [
13+
"/node_modules/",
14+
"/%PUBLIC_DIR%/build/",
15+
"npm-debug.log",
16+
"yarn-error.log"
17+
],
18+
"conflict": {
19+
"symfony/framework-bundle": "<5.4"
20+
}
21+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"devDependencies": {
3+
"@hotwired/stimulus": "^3.0.0",
4+
"@symfony/stimulus-bridge": "^3.0.0",
5+
"@symfony/webpack-encore": "^1.7.0",
6+
"core-js": "^3.0.0",
7+
"regenerator-runtime": "^0.13.2",
8+
"webpack-notifier": "^1.6.0"
9+
},
10+
"license": "UNLICENSED",
11+
"private": true,
12+
"scripts": {
13+
"dev-server": "encore dev-server",
14+
"dev": "encore dev",
15+
"watch": "encore dev --watch",
16+
"build": "encore production --progress"
17+
}
18+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Install Yarn and run <fg=green>yarn install</>
2+
3+
* Start the development server: <fg=green>yarn encore dev-server</>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
const Encore = require('@symfony/webpack-encore');
2+
3+
// Manually configure the runtime environment if not already configured yet by the "encore" command.
4+
// It's useful when you use tools that rely on webpack.config.js file.
5+
if (!Encore.isRuntimeEnvironmentConfigured()) {
6+
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
7+
}
8+
9+
Encore
10+
// directory where compiled assets will be stored
11+
.setOutputPath('public/build/')
12+
// public path used by the web server to access the output path
13+
.setPublicPath('/build')
14+
// only needed for CDN's or sub-directory deploy
15+
//.setManifestKeyPrefix('build/')
16+
17+
/*
18+
* ENTRY CONFIG
19+
*
20+
* Each entry will result in one JavaScript file (e.g. app.js)
21+
* and one CSS file (e.g. app.css) if your JavaScript imports CSS.
22+
*/
23+
.addEntry('app', './assets/app.js')
24+
25+
// enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
26+
.enableStimulusBridge('./assets/controllers.json')
27+
28+
// When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
29+
.splitEntryChunks()
30+
31+
// will require an extra script tag for runtime.js
32+
// but, you probably want this, unless you're building a single-page app
33+
.enableSingleRuntimeChunk()
34+
35+
/*
36+
* FEATURE CONFIG
37+
*
38+
* Enable & configure other features below. For a full
39+
* list of features, see:
40+
* https://symfony.com/doc/current/frontend.html#adding-more-features
41+
*/
42+
.cleanupOutputBeforeBuild()
43+
.enableBuildNotifications()
44+
.enableSourceMaps(!Encore.isProduction())
45+
// enables hashed filenames (e.g. app.abc123.css)
46+
.enableVersioning(Encore.isProduction())
47+
48+
.configureBabel((config) => {
49+
config.plugins.push('@babel/plugin-proposal-class-properties');
50+
})
51+
52+
// enables @babel/preset-env polyfills
53+
.configureBabelPresetEnv((config) => {
54+
config.useBuiltIns = 'usage';
55+
config.corejs = 3;
56+
})
57+
58+
// enables Sass/SCSS support
59+
//.enableSassLoader()
60+
61+
// uncomment if you use TypeScript
62+
//.enableTypeScriptLoader()
63+
64+
// uncomment if you use React
65+
//.enableReactPreset()
66+
67+
// uncomment to get integrity="..." attributes on your script & link tags
68+
// requires WebpackEncoreBundle 1.4 or higher
69+
//.enableIntegrityHashes(Encore.isProduction())
70+
71+
// uncomment if you're having problems with a jQuery plugin
72+
//.autoProvidejQuery()
73+
;
74+
75+
module.exports = Encore.getWebpackConfig();

0 commit comments

Comments
 (0)