This repository was archived by the owner on May 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
85 lines (69 loc) 路 2.5 KB
/
Copy pathwebpack.config.js
File metadata and controls
85 lines (69 loc) 路 2.5 KB
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
/**
* Webpack configuration.
*
* @requires composer-package:symfony/flex
* @requires composer-recipe:encore
*
* @requires module:babel-preset-env
* @requires module:babel-preset-es2015
* @requires module:babel-preset-react
* @requires module:babel-preset-stage-0
* @requires module:babel-plugin-syntax-dynamic-import
* @requires module:node-sass
* @requires module:sass-loader
* @requires module:webpack-notifier
*
* @author WebberTakken <webber@takken.io>.
*/
const Encore = require('@symfony/webpack-encore');
Encore
// The project directory where compiled assets will be stored
.setOutputPath('public')
// The public path used by the web server to access the previous directory
.setPublicPath('/')
// Empty the output directory between each build, leaving static files
.cleanupOutputBeforeBuild(['public'], (options) => {
options.verbose = true;
options.root = __dirname;
options.exclude = ['.htaccess', 'index.php', 'static', 'bundles'];
})
// Render all final CSS and JS files with source maps to help debugging
.enableSourceMaps(!Encore.isProduction())
// Create hashed file names (e.g. app.abc123.css)
.enableVersioning(Encore.isProduction())
// jQuery is required for Materialize.js
.autoProvidejQuery()
// Main scripts and styles definition
.createSharedEntry('app', './assets/app.jsx')
// Scene entries
.addEntry('scenes/maintenance', './assets/scenes/Maintenance')
.addEntry('scenes/demo/coreui', './assets/scenes/Demo/CoreUI')
.addEntry('scenes/demo/materialize', './assets/scenes/Demo/Materialize')
// Use Sass/SCSS files (node-sass, sass-loader)
.enableSassLoader()
.addLoader({ test: /\.scss$/, loader: 'import-glob-loader' })
// Enable notifications (webpack-notifier)
.enableBuildNotifications()
// Plugins
.configureBabel((config) => {
config.plugins.push(
// Enable using dynamic imports, using modular per-import chunks
['syntax-dynamic-import'],
);
})
// Presets
.configureBabel((config) => {
config.presets.push(
// Enable transpiling down to browser compatibility
['env', { targets: { browsers: ['last 2 versions', 'safari >= 7'] } }],
// Enable transpiling ES2015 to ES5 for uglifying non-ignored modules
['es2015'],
// Enable JSX/React
['react'],
// Enable ES6-strawman (babel-preset-*)
['stage-0'],
);
});
const config = Encore.getWebpackConfig();
config.module.rules[0].exclude = /node_modules\/(?!(autotrack|dom-utils))/;
module.exports = config;