Website/app/webpack.config.js

63 lines
1.6 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-12 22:56:04 +00:00
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/',
to: '../[path][name].[ext]',
pattern: /\.(?!scss|stylelint.*|json|woff).*$/
})
// Code Entries
.addEntry('app', './frontend/app.ts')
// Style Entries
//.addStyleEntry('name', './assets/styles/name.scss')
// 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-12 22:56:04 +00:00
.enableStimulusBridge('./frontend/controllers.json')
2023-10-29 17:01:21 +00:00
.enableSassLoader()
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
}
})
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;