-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·91 lines (77 loc) · 2.63 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const Encore = require('@symfony/webpack-encore');
const webpack = require('webpack');
Encore
// directory where compiled assets will be stored
.setOutputPath('public/build/')
// public path used by the web server to access the output path
.setPublicPath('/build')
// only needed for CDN's or subdirectory deploy
//.setManifestKeyPrefix('build/')
// Copy images from assets to the build directory
.copyFiles({
from: './assets/images',
to: 'images/[path][name].[ext]',
// Optional: If versioning is enabled, add the file hash too
// to: 'images/[path][name].[hash:8].[ext]',
// Optional: Only copy files matching this pattern
// pattern: /\.(png|jpg|jpeg)$/
})
/*
* ENTRY CONFIG
*
* Each entry will result in one JavaScript file (e.g. app.js)
* and one CSS file (e.g. app.css) if your JavaScript imports CSS.
*/
.addEntry('app', './assets/app.js')
.addEntry('completed', './assets/completed.js')
// enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
.enableStimulusBridge('./assets/controllers.json')
// Add aliases for modules
.addAliases({
'chart.js': 'chart.js/dist/Chart.js',
})
.enableSingleRuntimeChunk()
// Remove this line
// .autoProvidejQuery()
// Add loaders for CSS and images
.addLoader({
test: /\.css$/,
use: ['style-loader', 'css-loader'],
})
.addLoader({
test: /\.(jpe?g|png|gif)$/i,
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
},
})
// Add this configuration for handling CSS files from node_modules
.addRule({
test: /\.css$/,
include: /node_modules/,
use: ['style-loader', 'css-loader']
})
// Enable source maps during development
.enableSourceMaps(!Encore.isProduction())
// Enable versioning (cache-busting) in production
.enableVersioning(Encore.isProduction())
// Enable Sass/SCSS support
.enableSassLoader()
// Enable PostCSS support
.enablePostCssLoader()
// Add plugin to provide jQuery globally
.addPlugin(new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
}))
// Configure Sass loader with the new implementation
.configureBabelPresetEnv((config) => {
config.useBuiltIns = 'usage';
config.corejs = 3;
})
// Remove this line as it's not a valid Encore method
// .configureSassLoader(options => {
// options.implementation = require('sass');
// })
module.exports = Encore.getWebpackConfig();