瀏覽代碼

Installation webpack

master
Guillaume 3 年之前
父節點
當前提交
0a00f5b995
共有 25 個文件被更改,包括 5260 次插入26 次删除
  1. +7
    -0
      .gitignore
  2. +12
    -0
      assets/app.js
  3. +15
    -0
      assets/apps/backend/common/app.common.js
  4. +1
    -0
      assets/apps/backend/common/common.js
  5. +6
    -0
      assets/apps/backend/common/common.scss
  6. +11
    -0
      assets/bootstrap.js
  7. +4
    -0
      assets/controllers.json
  8. +16
    -0
      assets/controllers/hello_controller.js
  9. +3
    -0
      assets/styles/app.css
  10. +1
    -0
      composer.json
  11. +72
    -1
      composer.lock
  12. +1
    -0
      config/bundles.php
  13. +3
    -0
      config/packages/assets.yaml
  14. +4
    -0
      config/packages/prod/webpack_encore.yaml
  15. +2
    -0
      config/packages/test/webpack_encore.yaml
  16. +30
    -0
      config/packages/webpack_encore.yaml
  17. +13
    -0
      config/services.yaml
  18. +20
    -0
      package.json
  19. +7
    -0
      src/Controller/Admin/DashboardController.php
  20. +20
    -20
      src/Controller/Admin/PageCrudController.php
  21. +1
    -1
      src/Twig/TwigExtension.php
  22. +22
    -0
      symfony.lock
  23. +6
    -4
      templates/base.html.twig
  24. +77
    -0
      webpack.config.js
  25. +4906
    -0
      yarn.lock

+ 7
- 0
.gitignore 查看文件

@@ -27,3 +27,10 @@
###> liip/imagine-bundle ###
/public/media/cache/
###< liip/imagine-bundle ###

###> symfony/webpack-encore-bundle ###
/node_modules/
/public/build/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###

+ 12
- 0
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';

+ 15
- 0
assets/apps/backend/common/app.common.js 查看文件

@@ -0,0 +1,15 @@
/*
* 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 './common.scss';
import './common.js';

// start the Stimulus application
//import './bootstrap';

alert('Yo !') ;

+ 1
- 0
assets/apps/backend/common/common.js 查看文件

@@ -0,0 +1 @@


+ 6
- 0
assets/apps/backend/common/common.scss 查看文件

@@ -0,0 +1,6 @@

$color: red ;

body {
background-color: $color ;
}

+ 11
- 0
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
- 0
assets/controllers.json 查看文件

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

+ 16
- 0
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
- 0
assets/styles/app.css 查看文件

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

+ 1
- 0
composer.json 查看文件

@@ -43,6 +43,7 @@
"symfony/twig-bundle": "^5.2",
"symfony/validator": "5.2.*",
"symfony/web-link": "5.2.*",
"symfony/webpack-encore-bundle": "^1.11",
"symfony/yaml": "5.2.*",
"twig/extra-bundle": "^2.12|^3.0",
"twig/twig": "^2.12|^3.0"

+ 72
- 1
composer.lock 查看文件

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "813d067c880792b52c84288d5d1addf7",
"content-hash": "2108a57a09a39568569da93f03a4f797",
"packages": [
{
"name": "artgris/filemanager-bundle",
@@ -8237,6 +8237,77 @@
],
"time": "2021-03-07T15:51:33+00:00"
},
{
"name": "symfony/webpack-encore-bundle",
"version": "v1.11.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/webpack-encore-bundle.git",
"reference": "f282fb17ffa4839ba491eb7e3f5ffdd40c86f969"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/webpack-encore-bundle/zipball/f282fb17ffa4839ba491eb7e3f5ffdd40c86f969",
"reference": "f282fb17ffa4839ba491eb7e3f5ffdd40c86f969",
"shasum": ""
},
"require": {
"php": ">=7.1.3",
"symfony/asset": "^4.4 || ^5.0",
"symfony/config": "^4.4 || ^5.0",
"symfony/dependency-injection": "^4.4 || ^5.0",
"symfony/http-kernel": "^4.4 || ^5.0",
"symfony/service-contracts": "^1.0 || ^2.0"
},
"require-dev": {
"symfony/framework-bundle": "^4.4 || ^5.0",
"symfony/phpunit-bridge": "^4.4 || ^5.0",
"symfony/twig-bundle": "^4.4 || ^5.0",
"symfony/web-link": "^4.4 || ^5.0"
},
"type": "symfony-bundle",
"extra": {
"thanks": {
"name": "symfony/webpack-encore",
"url": "https://github.com/symfony/webpack-encore"
}
},
"autoload": {
"psr-4": {
"Symfony\\WebpackEncoreBundle\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Integration with your Symfony app & Webpack Encore!",
"support": {
"issues": "https://github.com/symfony/webpack-encore-bundle/issues",
"source": "https://github.com/symfony/webpack-encore-bundle/tree/v1.11.2"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-04-26T12:48:17+00:00"
},
{
"name": "symfony/yaml",
"version": "v5.2.7",

+ 1
- 0
config/bundles.php 查看文件

@@ -19,4 +19,5 @@ return [
FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],
Artgris\Bundle\FileManagerBundle\ArtgrisFileManagerBundle::class => ['all' => true],
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
];

+ 3
- 0
config/packages/assets.yaml 查看文件

@@ -0,0 +1,3 @@
framework:
assets:
json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'

+ 4
- 0
config/packages/prod/webpack_encore.yaml 查看文件

@@ -0,0 +1,4 @@
#webpack_encore:
# Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)
# Available in version 1.2
#cache: true

+ 2
- 0
config/packages/test/webpack_encore.yaml 查看文件

@@ -0,0 +1,2 @@
#webpack_encore:
# strict_mode: false

+ 30
- 0
config/packages/webpack_encore.yaml 查看文件

@@ -0,0 +1,30 @@
webpack_encore:
# The path where Encore is building the assets - i.e. Encore.setOutputPath()
output_path: '%kernel.project_dir%/public/build'
# If multiple builds are defined (as shown below), you can disable the default build:
# output_path: false

# 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 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:
# builds:
# pass "frontend" as the 3rg arg to the Twig functions
# {{ encore_entry_script_tags('entry1', null, 'frontend') }}

# frontend: '%kernel.project_dir%/public/frontend/build'

# Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)
# Put in config/packages/prod/webpack_encore.yaml
# cache: true

+ 13
- 0
config/services.yaml 查看文件

@@ -43,5 +43,18 @@ services:
resource: '../Lc/SovBundle/Controller/'
tags: [ 'controller.service_arguments' ]


Lc\CaracoleBundle\:
resource: '../Lc/CaracoleBundle/'
exclude:
- '../Lc/CaracoleBundle/DependencyInjection/'
- '../Lc/CaracoleBundle/Entity/'
- '../Lc/CaracoleBundle/Kernel.php'
- '../Lc/CaracoleBundle/Tests/'

Lc\CaracoleBundle\Controller\:
resource: '../Lc/CaracoleBundle/Controller/'
tags: [ 'controller.service_arguments' ]

# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones

+ 20
- 0
package.json 查看文件

@@ -0,0 +1,20 @@
{
"devDependencies": {
"@symfony/stimulus-bridge": "^2.0.0",
"@symfony/webpack-encore": "^1.0.0",
"core-js": "^3.0.0",
"regenerator-runtime": "^0.13.2",
"sass": "^1.32.12",
"sass-loader": "^11.0.0",
"stimulus": "^2.0.0",
"webpack-notifier": "^1.6.0"
},
"license": "UNLICENSED",
"private": true,
"scripts": {
"dev-server": "encore dev-server",
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress"
}
}

+ 7
- 0
src/Controller/Admin/DashboardController.php 查看文件

@@ -7,12 +7,19 @@ use App\Entity\Common\TaxRate;
use App\Entity\Site\Page;
use App\Entity\User\GroupUser;
use App\Entity\User\User;
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use Lc\SovBundle\Controller\Admin\DashboardController as LcDashboardController;

class DashboardController extends LcDashboardController
{

public function configureAssets(): Assets
{

return parent::configureAssets(); // TODO: Change the autogenerated stub
}

/*public function configureMenuItems(): iterable
{
$submenu1 = [

+ 20
- 20
src/Controller/Admin/PageCrudController.php 查看文件

@@ -3,6 +3,7 @@
namespace App\Controller\Admin;

use App\Entity\Site\Page;
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
@@ -13,26 +14,25 @@ use Lc\SovBundle\Field\GalleryManagerField;

class PageCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Page::class;
}
public static function getEntityFqcn(): string
{
return Page::class;
}


public function configureFields(string $pageName): iterable
{
return [
TextField::new('title'),
CKEditorField::new('description'),
FileManagerField::new('image'),
GalleryManagerField::new('gallery'),
TextField::new('devAlias'),
ChoiceField::new('status')
->setChoices(['En ligne' => 1, 'Hors ligne' => 0])
->setFormTypeOption('expanded', true)
->setFormTypeOption('multiple', false)
->setCustomOption('widget', false)
];
}
public function configureFields(string $pageName): iterable
{
return [
TextField::new('title'),
CKEditorField::new('description'),
FileManagerField::new('image'),
GalleryManagerField::new('gallery'),
TextField::new('devAlias'),
ChoiceField::new('status')
->setChoices(['En ligne' => 1, 'Hors ligne' => 0])
->setFormTypeOption('expanded', true)
->setFormTypeOption('multiple', false)
->setCustomOption('widget', false)
];
}

}

+ 1
- 1
src/Twig/TwigExtension.php 查看文件

@@ -2,7 +2,7 @@

namespace App\Twig;

use App\Entity\Page;
use App\Entity\Site\Page;
use Lc\SovBundle\Doctrine\EntityManager;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;

+ 22
- 0
symfony.lock 查看文件

@@ -579,6 +579,28 @@
"config/routes/dev/web_profiler.yaml"
]
},
"symfony/webpack-encore-bundle": {
"version": "1.9",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.9",
"ref": "9399a0bfc6ee7a0c019f952bca46d6a6045dd451"
},
"files": [
"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",
"config/packages/webpack_encore.yaml",
"package.json",
"webpack.config.js"
]
},
"symfony/yaml": {
"version": "v5.2.7"
},

+ 6
- 4
templates/base.html.twig 查看文件

@@ -27,9 +27,9 @@

<link rel="icon" type="image/png" href="{{ asset('assets/img/favicon.png') }}"/>

{% block stylesheets %}{% endblock %}
{% block stylesheets %}
{{ encore_entry_link_tags('backend-common') }}
{% endblock %}
</head>
<body>
{% block body %}
@@ -51,6 +51,8 @@

{% endblock %}

{% block javascripts %}{% endblock %}
{% block javascripts %}
{{ encore_entry_script_tags('backend-common') }}
{% endblock %}
</body>
</html>

+ 77
- 0
webpack.config.js 查看文件

@@ -0,0 +1,77 @@
const Encore = require('@symfony/webpack-encore');

// Manually configure the runtime environment if not already configured yet by the "encore" command.
// It's useful when you use tools that rely on webpack.config.js file.
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}

Encore
// directory where compiled assets will be stored
.setOutputPath('public/build/')
// public path used by the web server to access the output path
.setPublicPath('/build')
// only needed for CDN's or sub-directory deploy
//.setManifestKeyPrefix('build/')
.enableSassLoader()
/*
* ENTRY CONFIG
*
* 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('backend-common', './assets/apps/backend/common/app.common.js')
.addEntry('backend-common', './Lc/SovBundle/Resources/assets/apps/backend/common/app.common.js')
//.addEntry('easyadmin', './vendor/easycorp/easyadmin-bundle/assets/js/app.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()

// will require an extra script tag for runtime.js
// but, you probably want this, unless you're building a single-page app
.enableSingleRuntimeChunk()

/*
* FEATURE CONFIG
*
* Enable & configure other features below. For a full
* list of features, see:
* https://symfony.com/doc/current/frontend.html#adding-more-features
*/
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
// 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';
config.corejs = 3;
})

// enables Sass/SCSS support
//.enableSassLoader()

// 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()
;

module.exports = Encore.getWebpackConfig();

+ 4906
- 0
yarn.lock
文件差異過大導致無法顯示
查看文件


Loading…
取消
儲存