From deb6f26836b71a440128f7b3d90ca33826766e3e Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 16 Jun 2020 00:07:39 +0100 Subject: [PATCH] Add webpack aliases for CSS and JS directories --- web/themes/custom/opdavies/assets/js/app.js | 2 +- web/themes/custom/opdavies/webpack.config.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/web/themes/custom/opdavies/assets/js/app.js b/web/themes/custom/opdavies/assets/js/app.js index 3d1238a..a8af93a 100644 --- a/web/themes/custom/opdavies/assets/js/app.js +++ b/web/themes/custom/opdavies/assets/js/app.js @@ -1,5 +1,5 @@ -import '../css/tailwind.pcss' import 'alpinejs' +import 'styles/tailwind.pcss' import hljs from 'highlightjs' document.addEventListener('DOMContentLoaded', event => { diff --git a/web/themes/custom/opdavies/webpack.config.js b/web/themes/custom/opdavies/webpack.config.js index 45a4507..5afba99 100644 --- a/web/themes/custom/opdavies/webpack.config.js +++ b/web/themes/custom/opdavies/webpack.config.js @@ -1,4 +1,5 @@ let Encore = require('@symfony/webpack-encore') +let path = require('path') Encore .disableSingleRuntimeChunk() @@ -6,10 +7,15 @@ Encore .setOutputPath('build/') .setPublicPath('/themes/custom/opdavies/build') - .addEntry('app', './assets/js/app.js') + .addEntry('app', '@/app.js') .enablePostCssLoader() + .addAliases({ + '@': path.resolve(__dirname, 'assets', 'js'), + styles: path.resolve(__dirname, 'assets', 'css') + }) + if (!Encore.isProduction()) { Encore.enableSourceMaps() }