Website/webpack.config.js
Snoweuph 5f7e43113e
Some checks failed
Quality Check / QS Backend (push) Successful in 15s
Quality Check / QS Frontend (push) Failing after 1m10s
NOTICKET: Refactor Project Layout
2024-07-30 05:43:44 +02:00

68 lines
1.9 KiB
JavaScript

const Encore = require('@symfony/webpack-encore');
const {TsconfigPathsPlugin} = require('tsconfig-paths-webpack-plugin');
const path = require('path');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}
const TS_CONFIG_PATH = path.resolve('tsconfig.json');
Encore
// Paths and Files
.setOutputPath('public/build/')
.setPublicPath('/build')
.copyFiles({
from: './assets/',
to: '../[path][name].[ext]'
})
.addEntry('app', './src/Framework/app.ts')
// Webpack
.splitEntryChunks()
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
.enableVersioning(Encore.isProduction())
// Packages
.configureBabelPresetEnv((config) => {
config.useBuiltIns = 'usage';
config.corejs = '3.23';
})
.enableStimulusBridge('./src/Framework/Package/controllers.json')
.enableSassLoader()
.enablePostCssLoader()
.enableTypeScriptLoader(function tsconfigCallback(tsConfig) {
tsConfig.configFile = TS_CONFIG_PATH;
})
.enableForkedTypeScriptTypesChecking(function (forkedTsConfig) {
forkedTsConfig.typescript = {
configFile: TS_CONFIG_PATH
};
})
.addPlugin(new BrowserSyncPlugin({
proxy: 'http://localhost:8000',
files: [
'src/**/*.twig',
'src/**/*.scss',
'src/**/*.ts',
],
reload: true,
open: true,
notify: false
}))
.addAliases({
'@component': path.resolve(__dirname, 'src/Component')
})
;
const config = Encore.getWebpackConfig();
config.resolve.plugins = [
new TsconfigPathsPlugin({
configFile: TS_CONFIG_PATH,
})
];
module.exports = config;