- {{ form_label(form.filename) }}
- {{ form_errors(form.filename) }}
- {{ form_widget(form.filename, {'attr': {'class':'hidden'}}) }}
-
+
- {{ form_rest(form) }}
+ {% include 'MajoraOTAStoreAppBundle:Includes:form_errors.html.twig' %}
-
-
- {{ 'build.form.submit_button.label'|trans }}
-
- {{ form_end(form) }}
+
{% endblock %}
{% block javascripts %}
@@ -26,11 +60,3 @@
{{ include('MajoraOTAStoreAppBundle::upload-container-template.html.twig') }}
{% endblock %}
-
-{% block stylesheets %}
- {{ parent() }}
-
- {% if not use_webpack_dev_server %}
-
- {% endif %}
-{% endblock %}
diff --git a/src/ApplicationBundle/Resources/views/Build/list.html.twig b/src/ApplicationBundle/Resources/views/Build/list.html.twig
index 9b4fc9d..08eb856 100644
--- a/src/ApplicationBundle/Resources/views/Build/list.html.twig
+++ b/src/ApplicationBundle/Resources/views/Build/list.html.twig
@@ -1,82 +1,146 @@
-{% extends 'MajoraOTAStoreApplicationBundle::layout.html.twig'%}
+{% extends 'MajoraOTAStoreAppBundle:Layout:layout_authenticated.html.twig' %}
{% block title 'build.list.title'|trans %}
-{% block header %}
-
{{ 'build.list.title'|trans }}
-
+{% block content %}
+
+
-
-{% endblock %}
+
+
+
+
+
+
{{ 'build.list.thead.label'|trans }}
+
+
+
+
{{ 'build.list.thead.actions'|trans }}
+
+
-{% block content %}
-
+
+
+
+ {# TODO pagination #}
+ {##}
{% endblock %}
diff --git a/src/ApplicationBundle/Resources/views/Build/update.html.twig b/src/ApplicationBundle/Resources/views/Build/update.html.twig
index d4f95c4..a16635e 100644
--- a/src/ApplicationBundle/Resources/views/Build/update.html.twig
+++ b/src/ApplicationBundle/Resources/views/Build/update.html.twig
@@ -1,15 +1,9 @@
-{% extends 'MajoraOTAStoreApplicationBundle:Build:form.html.twig'%}
+{% extends 'MajoraOTAStoreApplicationBundle:Build:form.html.twig' %}
{% block title 'build.update.title'|trans %}
-{% block header %}
-
{{ 'build.update.title'|trans }}
-
+{% block extra_buttons %}
+
+ {{ form.vars.data.enabled ? 'build.form.disable.label'|trans : 'build.form.enable.label'|trans }}
+
{% endblock %}
-
-{% block build_form_action url('majoraotastore_admin_build_update', {'application_id': application.id, 'id': build.id }) %}
diff --git a/src/ApplicationBundle/Resources/views/layout.html.twig b/src/ApplicationBundle/Resources/views/layout.html.twig
deleted file mode 100644
index e2bfbc3..0000000
--- a/src/ApplicationBundle/Resources/views/layout.html.twig
+++ /dev/null
@@ -1 +0,0 @@
-{% extends 'MajoraOTAStoreAppBundle::layout.html.twig' %}
diff --git a/src/ApplicationBundle/Service/BuildUploadHelper.php b/src/ApplicationBundle/Service/BuildUploadHelper.php
index 7c10f55..9611be3 100644
--- a/src/ApplicationBundle/Service/BuildUploadHelper.php
+++ b/src/ApplicationBundle/Service/BuildUploadHelper.php
@@ -106,14 +106,14 @@ public function moveUploadedFile(File $uploadedFile, Application $application, $
*/
public function createTempFile($fileContent, $filename)
{
- $filePath = DIRECTORY_SEPARATOR.
- trim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).
- DIRECTORY_SEPARATOR.
- ltrim($filename, DIRECTORY_SEPARATOR);
-
- $writeRes = file_put_contents($filePath, $fileContent);
+ $filePath = sprintf(
+ '%s%s%s',
+ rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR),
+ DIRECTORY_SEPARATOR,
+ ltrim($filename, DIRECTORY_SEPARATOR)
+ );
- if ($writeRes === false) {
+ if (file_put_contents($filePath, $fileContent) === false) {
throw new FileException(sprintf('Could not create temp file "%s"', $fileContent));
}
diff --git a/src/UserBundle/Controller/SecurityController.php b/src/UserBundle/Controller/SecurityController.php
index 099f509..573f1f6 100644
--- a/src/UserBundle/Controller/SecurityController.php
+++ b/src/UserBundle/Controller/SecurityController.php
@@ -85,7 +85,7 @@ public function createAction(Request $request)
if ($request->isMethod(Request::METHOD_POST)) {
$form->handleRequest($request);
- if ($form->isValid()) {
+ if ($form->isSubmitted() && $form->isValid()) {
// Encode password
if (!$password = $form->get('password')->getData()) {
throw new ValidatorException('Password must be set.');
@@ -93,7 +93,7 @@ public function createAction(Request $request)
$user->setPassword($this->container->get('security.password_encoder')->encodePassword($user, $password));
// Set role
- if ($role = $form->get('roles')->getData()) {
+ if ($role = $form->get('role')->getData()) {
$user->setRoles([$role]);
}
@@ -103,7 +103,7 @@ public function createAction(Request $request)
$this->addFlash('success', $this->container->get('translator')->trans('user.create.flash.success'));
- return $this->redirectToRoute('majoraotastore_admin_user_create');
+ return $this->redirectToRoute('majoraotastore_admin_user_list');
}
}
@@ -135,14 +135,14 @@ public function updateAction(User $user, Request $request)
if ($request->isMethod(Request::METHOD_POST)) {
$form->handleRequest($request);
- if ($form->isValid()) {
+ if ($form->isSubmitted() && $form->isValid()) {
// Encode password if it is set
if ($password = $form->get('password')->getData()) {
$user->setPassword($this->container->get('security.password_encoder')->encodePassword($user, $password));
}
// Set role
- if ($role = $form->get('roles')->getData()) {
+ if ($role = $form->get('role')->getData()) {
$user->setRoles([$role]);
}
@@ -152,9 +152,7 @@ public function updateAction(User $user, Request $request)
$this->addFlash('success', $this->container->get('translator')->trans('user.update.flash.success'));
- return new RedirectResponse($this->container->get('router')->generate(
- 'majoraotastore_admin_user_list'
- ));
+ return $this->redirectToRoute('majoraotastore_admin_user_list');
}
}
@@ -162,7 +160,6 @@ public function updateAction(User $user, Request $request)
'MajoraOTAStoreUserBundle:Security:update.html.twig',
[
'form' => $form->createView(),
- 'user' => $user,
]
);
}
@@ -235,7 +232,7 @@ public function myAccountAction(Request $request)
);
$form->handleRequest($request);
- if ($form->isValid()) {
+ if ($form->isSubmitted() && $form->isValid()) {
// Encode password if it is set
if ($password = $form->get('password')->getData()) {
$user->setPassword($this->container->get('security.password_encoder')->encodePassword($user, $password));
diff --git a/src/UserBundle/Form/Type/UserType.php b/src/UserBundle/Form/Type/UserType.php
index bac1146..3637c6f 100644
--- a/src/UserBundle/Form/Type/UserType.php
+++ b/src/UserBundle/Form/Type/UserType.php
@@ -2,6 +2,7 @@
namespace Majora\OTAStore\UserBundle\Form\Type;
+use Majora\OTAStore\UserBundle\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type;
use Symfony\Component\Form\FormBuilderInterface;
@@ -15,57 +16,60 @@ class UserType extends AbstractType
const TOKEN_EDITION = 'edition';
const TOKEN_MY_ACCOUNT = 'my-account';
+ /**
+ * {@inheritdoc}
+ */
+ public function getBlockPrefix()
+ {
+ return 'majoraotastore_user';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $resolver->setDefaults([
+ 'data_class' => User::class,
+ 'csrf_protection' => true,
+ 'allow_extra_fields' => false,
+ 'csrf_token_id' => null,
+ ]);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('email', Type\EmailType::class, [
- 'label' => 'user.edit.email.label',
- ])
- ->add('firstname', Type\TextType::class, [
- 'label' => 'user.edit.firstname.label',
- ])
- ->add('lastname', Type\TextType::class, [
- 'label' => 'user.edit.lastname.label',
- ])
+ ->add('email', Type\EmailType::class, ['error_bubbling' => true])
+ ->add('firstname', Type\TextType::class, ['error_bubbling' => true])
+ ->add('lastname', Type\TextType::class, ['error_bubbling' => true])
->add('password', Type\RepeatedType::class, [
+ 'error_bubbling' => true,
'type' => Type\PasswordType::class,
- 'first_options' => ['label' => 'user.edit.password.label.first'],
- 'second_options' => ['label' => 'user.edit.password.label.second'],
- 'required' => $options['csrf_token_id'] === self::TOKEN_CREATION,
'mapped' => false,
])
;
- // Roles can't be set for "my-account" csrf_token_id
+ // Roles can't be set for "my-account"
if ($options['csrf_token_id'] !== self::TOKEN_MY_ACCOUNT) {
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$userRole = $event->getData()->getRole();
$form = $event->getForm();
- $form->add('roles', Type\ChoiceType::class, [
- 'label' => 'user.edit.role.label',
+ $form->add('role', Type\ChoiceType::class, [
+ 'error_bubbling' => true,
'choices' => [
- 'user.roles.ROLE_USER' => 'ROLE_USER',
- 'user.roles.ROLE_ADMIN' => 'ROLE_ADMIN',
- 'user.roles.ROLE_SUPER_ADMIN' => 'ROLE_SUPER_ADMIN',
+ 'ROLE_USER',
+ 'ROLE_ADMIN',
+ 'ROLE_SUPER_ADMIN',
],
- 'choices_as_values' => true,
- 'mapped' => false,
'data' => $userRole,
+ 'mapped' => false,
]);
});
}
}
-
- public function configureOptions(OptionsResolver $resolver)
- {
- $resolver->setDefaults([
- 'data_class' => 'Majora\OTAStore\UserBundle\Entity\User',
- ]);
- }
-
- public function getBlockPrefix()
- {
- return 'majoraotastore_user';
- }
}
diff --git a/src/UserBundle/Resources/doc/index.rst b/src/UserBundle/Resources/doc/index.rst
deleted file mode 100644
index e69de29..0000000
diff --git a/src/UserBundle/Resources/translations/messages.en.yml b/src/UserBundle/Resources/translations/messages.en.yml
index 41baa4f..a3d8d4e 100644
--- a/src/UserBundle/Resources/translations/messages.en.yml
+++ b/src/UserBundle/Resources/translations/messages.en.yml
@@ -1,59 +1,80 @@
# Majora => UserBundle => messages.fr
user:
roles:
- ROLE_USER: Downloader (download applications)
- ROLE_ADMIN: Admin (Downloader + create applications + give access to applications)
- ROLE_SUPER_ADMIN: Super Admin (Admin + create and edit users)
+ ROLE_USER:
+ label: Downloader
+ description: ''
+ letter: D
+ ROLE_ADMIN:
+ label: Admin
+ description: ''
+ letter: A
+ ROLE_SUPER_ADMIN:
+ label: Super Admin
+ description: (admin and users management)
+ letter: S
login:
title: Login
form:
email:
- label: Email :
+ label: email
password:
- label: Password :
+ label: password
remember_me:
- label: Keep me logged in
- submit: Login
+ label: keep me logged in
+ submit: login
logout:
title: Logout
list:
- title: Users
+ title: users
+ buttons:
+ disabled_users: disabled users
+ enabled_users: enabled users
thead:
firstname: Firstname
lastname: Lastname
role: Role
email: Email
- actions: Actions
- actions:
- update:
- title: Edit user
- enable:
- title: Enable user
- disable:
- title: Disable user
+ form:
+ lastname:
+ label: Lastname
+ placeholder: lastname
+ error: This field is mandatory
+ firstname:
+ label: Firstname
+ placeholder: firstname
+ error: This field is mandatory
+ email:
+ label: Email address
+ placeholder: email address
+ error: This field is mandatory
+ password:
+ label: Password
+ placeholder: new password
+ error: This field is mandatory
+ password_confirm:
+ label: Confirm
+ placeholder: repeat password
+ error: Password is not identical
+ role:
+ label: Role
+ submit:
+ label: save
+ cancel:
+ label: cancel
+ disable:
+ label: disable user
+ enable:
+ label: enable user
create:
- title: New user
+ title: create a new user
flash:
success: User was successfully created
update:
- title: Update user
+ title: edit user
flash:
success: User was successfully updated
my_account:
- title: My account
+ title: my account
flash:
success: Your account was successfully updated
- edit:
- submit: Save
- email:
- label: Email :
- firstname:
- label: Firstname :
- lastname:
- label: Lastname :
- password:
- label:
- first: Password :
- second: Repeat the password :
- role:
- label: Role
diff --git a/src/UserBundle/Resources/translations/messages.fr.yml b/src/UserBundle/Resources/translations/messages.fr.yml
index 7d53545..59bac75 100644
--- a/src/UserBundle/Resources/translations/messages.fr.yml
+++ b/src/UserBundle/Resources/translations/messages.fr.yml
@@ -1,59 +1,80 @@
# Majora => UserBundle => messages.fr
user:
roles:
- ROLE_USER: Téléchargeur (télécharger des app)
- ROLE_ADMIN: Admin (Téléchargeur + créer des app + donner accès aux app)
- ROLE_SUPER_ADMIN: Super Admin (Admin + créer et modifier des utilisateurs)
+ ROLE_USER:
+ label: Téléchargeur
+ description: ''
+ letter: T
+ ROLE_ADMIN:
+ label: Admin
+ description: ''
+ letter: A
+ ROLE_SUPER_ADMIN:
+ label: Super administrateur
+ description: (admin et gestion des utilisateurs)
+ letter: S
login:
title: Connectez-vous
form:
email:
- label: Email :
+ label: email
password:
- label: Mot de passe :
+ label: mot de passe
remember_me:
- label: Se souvenir de moi
- submit: Se connecter
+ label: se souvenir de moi
+ submit: se connecter
logout:
title: Se déconnecter
list:
- title: Utilisateurs
+ title: utilisateurs
+ buttons:
+ disabled_users: utilisateurs désactivés
+ enabled_users: utilisateurs activés
thead:
firstname: Prénom
lastname: Nom
role: Rôle
email: Email
- actions: Actions
- actions:
- update:
- title: Modifier l'utilisateur
- enable:
- title: Activer l'utilisateur
- disable:
- title: Désactiver l'utilisateur
+ form:
+ lastname:
+ label: Nom
+ placeholder: nom
+ error: Le champ est obligatoire
+ firstname:
+ label: Prénom
+ placeholder: prénom
+ error: Le champ est obligatoire
+ email:
+ label: Adresse mail
+ placeholder: adresse mail
+ error: Le champ est obligatoire
+ password:
+ label: Mot de passe
+ placeholder: nouveau mot de passe
+ error: Le champ est obligatoire
+ password_confirm:
+ label: Confirmation
+ placeholder: répétez le mot de passe
+ error: Le mot de passe n'est pas identique
+ role:
+ label: Role
+ submit:
+ label: sauvegarder
+ cancel:
+ label: annuler
+ disable:
+ label: désactiver l'utilisateur
+ enable:
+ label: activer l'utilisateur
create:
- title: Créer un utilisateur
+ title: créer un nouvel utilisateur
flash:
success: L'utilisateur a bien été créé
update:
- title: Modifier un utilisateur
+ title: modifier un utilisateur
flash:
success: L'utilisateur a bien été mis à jour
my_account:
- title: Mon compte
+ title: mon compte
flash:
success: Votre compte a bien été mis à jour
- edit:
- submit: Enregistrer
- email:
- label: Email :
- firstname:
- label: Prénom :
- lastname:
- label: Nom :
- password:
- label:
- first: Mot de passe :
- second: Répéter le mot de passe :
- role:
- label: Rôle
diff --git a/src/UserBundle/Resources/views/Security/create.html.twig b/src/UserBundle/Resources/views/Security/create.html.twig
index 1704813..8d3902a 100644
--- a/src/UserBundle/Resources/views/Security/create.html.twig
+++ b/src/UserBundle/Resources/views/Security/create.html.twig
@@ -2,14 +2,5 @@
{% block title 'user.create.title'|trans %}
-{% block header %}
-
{{ 'user.create.title'|trans }}
-
-{% endblock %}
-
-{% block user_form_action url('majoraotastore_admin_user_create') %}
+{% block input_extra_params_password_first 'required' %}
+{% block extra_buttons '' %}
diff --git a/src/UserBundle/Resources/views/Security/forgot-password.html.twig b/src/UserBundle/Resources/views/Security/forgot-password.html.twig
new file mode 100644
index 0000000..9173195
--- /dev/null
+++ b/src/UserBundle/Resources/views/Security/forgot-password.html.twig
@@ -0,0 +1,24 @@
+
+{# TODO forgot password, based on login.html.twig #}
+
+
diff --git a/src/UserBundle/Resources/views/Security/form.html.twig b/src/UserBundle/Resources/views/Security/form.html.twig
index 164568e..709b866 100644
--- a/src/UserBundle/Resources/views/Security/form.html.twig
+++ b/src/UserBundle/Resources/views/Security/form.html.twig
@@ -1,19 +1,146 @@
-{% extends 'MajoraOTAStoreUserBundle::layout.html.twig' %}
+{% extends 'MajoraOTAStoreAppBundle:Layout:layout_authenticated.html.twig' %}
{% block content %}
- {{ form_start(form, {'method': 'POST', 'action': block('user_form_action')}) }}
- {{ form_row(form.firstname) }}
- {{ form_row(form.lastname) }}
- {{ form_row(form.email) }}
- {{ form_row(form.password.first) }}
- {{ form_row(form.password.second) }}
- {{ form_row(form.roles) }}
+
- {{ form_rest(form) }}
-
-
- {{ 'user.edit.submit'|trans }}
-
+ {% include 'MajoraOTAStoreAppBundle:Includes:form_errors.html.twig' %}
+
+
+
{% endblock %}
diff --git a/src/UserBundle/Resources/views/Security/list.html.twig b/src/UserBundle/Resources/views/Security/list.html.twig
index 7c403c2..ab77c67 100644
--- a/src/UserBundle/Resources/views/Security/list.html.twig
+++ b/src/UserBundle/Resources/views/Security/list.html.twig
@@ -1,75 +1,89 @@
-{% extends 'MajoraOTAStoreUserBundle::layout.html.twig' %}
+{% extends 'MajoraOTAStoreAppBundle:Layout:layout_authenticated.html.twig' %}
{% block title 'user.list.title'|trans %}
-{% block header %}
-
{{ 'user.list.title'|trans }}
-
+
+
+
+
+
+
{{ 'user.list.thead.role'|trans }}
+
+
+
{{ 'user.list.thead.email'|trans }}
+
+
+
{{ 'user.list.thead.firstname'|trans }}
+
+
+
{{ 'user.list.thead.lastname'|trans }}
+
+
+
-{% block content %}
-
-
-
- {{ 'user.list.thead.email'|trans }}
- {{ 'user.list.thead.firstname'|trans }}
- {{ 'user.list.thead.lastname'|trans }}
- {{ 'user.list.thead.role'|trans }}
-
- {{ 'user.list.thead.actions'|trans }}
-
-
-
-
{% for user in users %}
-
-
-
- {{ user.email }}
-
-
-
- {{ user.firstname }}
-
-
- {{ user.lastname }}
-
-
- {{ ('user.roles.'~user.role)|trans }}
-
-
-
-
-
- {% if user.enabled %}
-
-
-
- {% else %}
-
-
-
- {% endif %}
-
-
+
+
+
+ {{ ('user.roles.'~user.role~'.letter')|trans }}
+
+
+
+
+
+
+
{% endfor %}
-
-
+
+
+
+ {# TODO pagination #}
+ {##}
{% endblock %}
diff --git a/src/UserBundle/Resources/views/Security/login.html.twig b/src/UserBundle/Resources/views/Security/login.html.twig
index bdd1f73..ddc7865 100644
--- a/src/UserBundle/Resources/views/Security/login.html.twig
+++ b/src/UserBundle/Resources/views/Security/login.html.twig
@@ -1,46 +1,43 @@
-{% extends 'MajoraOTAStoreUserBundle:Security:form.html.twig' %}
+{% extends 'MajoraOTAStoreAppBundle:Layout:layout_anonymous.html.twig' %}
{% block title 'user.login.title'|trans %}
-{% block header %}
-
-
-
{{ 'admin.title' | trans }}
-
-
-{% endblock %}
+{% block section_class 'section-login' %}
{% block content %}
+
{% endblock %}
diff --git a/src/UserBundle/Resources/views/Security/my-account.html.twig b/src/UserBundle/Resources/views/Security/my-account.html.twig
index a837f67..957a431 100644
--- a/src/UserBundle/Resources/views/Security/my-account.html.twig
+++ b/src/UserBundle/Resources/views/Security/my-account.html.twig
@@ -2,22 +2,10 @@
{% block title 'user.my_account.title'|trans %}
-{% block content %}
-
-
-
{{ 'user.my_account.title' | trans }}
-
-
-
- {{ form_start(form) }}
- {{ form_row(form.firstname) }}
- {{ form_row(form.lastname) }}
- {{ form_row(form.email) }}
- {{ form_row(form.password.first) }}
- {{ form_row(form.password.second) }}
-
- {{ 'user.edit.submit' | trans }}
- {{ form_end(form) }}
-
-
+{% block cancel_button_url url('majoraotastore_admin_application_list') %}
+{% block extra_inputs '' %}
+{% block extra_buttons %}
+
+ {{ 'user.logout.title'|trans }}
+
{% endblock %}
diff --git a/src/UserBundle/Resources/views/Security/update.html.twig b/src/UserBundle/Resources/views/Security/update.html.twig
index b622cf0..d31a284 100644
--- a/src/UserBundle/Resources/views/Security/update.html.twig
+++ b/src/UserBundle/Resources/views/Security/update.html.twig
@@ -2,14 +2,8 @@
{% block title 'user.update.title'|trans %}
-{% block header %}
-
{{ 'user.update.title'|trans }}
-
+{% block extra_buttons %}
+
+ {{ form.vars.data.enabled ? 'user.form.disable.label'|trans : 'user.form.enable.label'|trans }}
+
{% endblock %}
-
-{% block user_form_action url('majoraotastore_admin_user_update', { 'id': user.id }) %}
diff --git a/src/UserBundle/Resources/views/layout.html.twig b/src/UserBundle/Resources/views/layout.html.twig
deleted file mode 100644
index e2bfbc3..0000000
--- a/src/UserBundle/Resources/views/layout.html.twig
+++ /dev/null
@@ -1 +0,0 @@
-{% extends 'MajoraOTAStoreAppBundle::layout.html.twig' %}
diff --git a/web/apple-touch-icon.png b/web/apple-touch-icon.png
deleted file mode 100644
index 11f17e6..0000000
Binary files a/web/apple-touch-icon.png and /dev/null differ
diff --git a/web/favicon.ico b/web/favicon.ico
deleted file mode 100644
index 479f7f5..0000000
Binary files a/web/favicon.ico and /dev/null differ
diff --git a/webpack.config.js b/webpack.config.js
index 9255a80..50ff28f 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -3,7 +3,6 @@ const isDev = require('isdev');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const { optimize } = require('webpack');
-
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractCSS = new ExtractTextPlugin({
filename: '[name].css?[contenthash]',
@@ -30,6 +29,7 @@ const config = {
rules: [
{
test: /\.js$/,
+ exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
@@ -39,52 +39,37 @@ const config = {
},
{
test: /\.css$/,
- use: isDev
- ? [
- {
- loader: 'style-loader',
- options: {sourceMap: true},
- },
+ use: extractCSS.extract({
+ fallback: {
+ loader: 'style-loader',
+ options: { sourceMap: true },
+ },
+ use: [
{
loader: 'css-loader',
- options: {sourceMap: true},
+ options: { sourceMap: true },
},
- ]
- : extractCSS.extract({
- fallback: 'style-loader',
- use: {
- loader: 'css-loader',
- },
- }),
+ ],
+ }),
},
{
test: /\.scss$/,
- use: isDev
- ? [
- {
- loader: 'style-loader',
- options: {sourceMap: true},
- },
+ use: extractSASS.extract({
+ fallback: {
+ loader: 'style-loader',
+ options: { sourceMap: true },
+ },
+ use: [
{
loader: 'css-loader',
- options: {sourceMap: true},
+ options: { sourceMap: true },
},
{
loader: 'sass-loader',
- options: {sourceMap: true},
+ options: { sourceMap: true },
},
- ]
- : extractSASS.extract({
- fallback: 'style-loader',
- use: [
- {
- loader: 'css-loader',
- },
- {
- loader: 'sass-loader',
- },
- ],
- }),
+ ],
+ }),
},
{
test: /\.(png|gif|jpg|svg|woff2?|ttf|eot)$/,
@@ -96,6 +81,14 @@ const config = {
},
plugins: [
new CopyWebpackPlugin([
+ {
+ from: './src/AppBundle/Resources/public/img',
+ to: 'img',
+ },
+ {
+ from: './src/AppBundle/Resources/public/favicons',
+ to: 'favicons',
+ },
{
from: './node_modules/jquery/dist/jquery.min.js',
to: 'jquery.js',
@@ -110,6 +103,8 @@ const config = {
},
]),
new optimize.CommonsChunkPlugin({ name: 'common', filename: 'common.js' }),
+ extractCSS,
+ extractSASS,
],
externals: {
jquery: 'jQuery',
@@ -121,17 +116,23 @@ const config = {
path.resolve(__dirname, 'node_modules'),
],
},
- devtool: 'cheap-module-source-map',
+ devtool: isDev ? 'cheap-module-eval-source-map' : 'source-map',
devServer: {
host: '0.0.0.0',
disableHostCheck: true,
},
};
-if (!isDev) {
- config.plugins.push(new UglifyJSPlugin());
- config.plugins.push(extractCSS);
- config.plugins.push(extractSASS);
+if (isDev) {
+ config.module.rules.push({
+ enforce: 'pre',
+ test: /\.js$/,
+ loader: 'eslint-loader',
+ });
+} else {
+ config.plugins.push(
+ new UglifyJSPlugin({ sourceMap: true })
+ );
}
module.exports = config;