Website/app/webpack.config.js

66 lines
1.8 KiB
JavaScript
Raw Normal View History

2024-07-12 22:56:04 +00:00
const Encore = require('@symfony/webpack-encore');
const {TsconfigPathsPlugin} = require("tsconfig-paths-webpack-plugin");
2024-04-22 18:52:51 +00:00
const path = require('path');
2024-07-14 14:26:52 +00:00
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
2024-04-22 18:52:51 +00:00
2023-10-29 17:01:21 +00:00
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}
2024-07-12 22:56:04 +00:00
const TS_CONFIG_PATH = path.resolve("frontend/tsconfig.json")
2024-04-22 18:52:51 +00:00
2023-10-29 17:01:21 +00:00
Encore
2024-07-12 22:56:04 +00:00
// Paths and Files
2023-10-29 17:01:21 +00:00
.setOutputPath('public/build/')
.setPublicPath('/build')
2024-07-12 22:56:04 +00:00
.copyFiles({
from: './assets/',
2024-07-20 06:38:12 +00:00
to: '../[path][name].[ext]'
2024-07-12 22:56:04 +00:00
})
.addEntry('app', './frontend/app.ts')
// Webpack
2024-04-22 18:52:51 +00:00
.splitEntryChunks()
2023-10-29 17:01:21 +00:00
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
.enableVersioning(Encore.isProduction())
2024-07-12 22:56:04 +00:00
// Packages
2023-10-29 17:01:21 +00:00
.configureBabelPresetEnv((config) => {
config.useBuiltIns = 'usage';
config.corejs = '3.23';
})
2024-07-20 06:38:12 +00:00
.enableStimulusBridge('./frontend/controllers/controllers.json')
2023-10-29 17:01:21 +00:00
.enableSassLoader()
2024-07-14 14:26:52 +00:00
.enablePostCssLoader()
2024-07-12 22:56:04 +00:00
.enableTypeScriptLoader(function tsconfigCallback(tsConfig) {
tsConfig.configFile = TS_CONFIG_PATH;
})
.enableForkedTypeScriptTypesChecking(function (forkedTsConfig) {
forkedTsConfig.typescript = {
configFile: TS_CONFIG_PATH
}
})
2024-07-14 14:26:52 +00:00
.addPlugin(new BrowserSyncPlugin({
proxy: 'http://localhost:8000',
files: [
'frontend/**/*.twig',
'frontend/**/*.scss',
'frontend/**/*.ts',
],
reload: true,
open: true,
notify: false
}))
2023-10-29 17:01:21 +00:00
;
2024-07-12 22:56:04 +00:00
const config = Encore.getWebpackConfig();
config.resolve.plugins = [
new TsconfigPathsPlugin({
configFile: TS_CONFIG_PATH,
})
];
module.exports = config;