Website/webpack.config.js

69 lines
1.9 KiB
JavaScript
Raw Normal View History

2024-07-12 22:56:04 +00:00
const Encore = require('@symfony/webpack-encore');
2024-07-30 03:36:45 +00:00
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-30 03:36:45 +00:00
const TS_CONFIG_PATH = path.resolve('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-30 03:36:45 +00:00
to: '../[path][name].[ext]'
2024-07-12 22:56:04 +00:00
})
2024-07-30 03:36:45 +00:00
.addEntry('app', './src/Framework/app.ts')
2024-07-12 22:56:04 +00:00
// 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-30 03:36:45 +00:00
.enableStimulusBridge('./src/Framework/Package/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-30 03:36:45 +00:00
};
2024-07-12 22:56:04 +00:00
})
2024-07-14 14:26:52 +00:00
.addPlugin(new BrowserSyncPlugin({
proxy: 'http://localhost:8000',
files: [
2024-07-30 03:36:45 +00:00
'src/**/*.twig',
'src/**/*.scss',
'src/**/*.ts',
2024-07-14 14:26:52 +00:00
],
reload: true,
open: true,
notify: false
}))
2024-07-30 03:36:45 +00:00
.addAliases({
'@component': path.resolve(__dirname, 'src/Component')
})
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;