sulu/webpack-encore

A package to install webpack encore into your package without stimilus.

Installs: 99

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 5

Forks: 0

Open Issues: 0

Language:JavaScript

1.0.0 2021-03-17 20:36 UTC

This package is auto-updated.

Last update: 2024-12-18 05:45:25 UTC


README

Simple Webpack Encore implementation, with sass-loader for css. This package provides a simple recipe for webpack encore to use without Stimilus integration and webpack-encore-bundle.

Installation

composer require sulu/webpack-encore

The symfony/flex recipe should now generate the CSS/JS setup in your project directories.

Build CSS / JS

cd assets/website
npm install
npm run build

Embed JS / CSS

The JS:

<script src="{{ asset('build/website/main.js', 'website') }}"></script>

The CSS:

<link href="{{ asset('build/website/main.css', 'website') }}" rel="stylesheet">

After embedding you should see a colored background. This means your build did successfully work.

Remove Package

Now the best is you can savely remove this package. That symfony flex will not remove the recipe files we just checkout the composer files.

git checkout symfony.lock composer.lock composer.json

Preloading CSS / JS

If you want to preload the CSS or CSS you can do this using the symfony/web-link package:

composer require symfony/asset
composer require symfony/web-link

After this just wrap the asset function in preload e.g.:

The JS:

<script src="{{ preload(asset('build/website/main.js', 'website')) }}"></script>

The CSS:

<link href="{{ preload(asset('build/website/main.css', 'website')) }}" rel="stylesheet">