-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
104 lines (100 loc) · 3.35 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
92
93
94
95
96
97
98
99
100
101
102
103
104
/* eslint-disable flowtype/require-valid-file-annotation */
/* eslint-disable import/no-nodejs-modules*/
const path = require('path');
const glob = require('glob');
const webpack = require('webpack');
const CleanObsoleteChunksPlugin = require('webpack-clean-obsolete-chunks');
const ManifestPlugin = require('webpack-manifest-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const entries = glob.sync(
path.resolve(__dirname, 'src/Sulu/Bundle/*/Resources/js/index.js') // eslint-disable-line no-undef
);
const entriesCount = entries.length;
entries.unshift('core-js/fn/array/includes');
entries.unshift('core-js/fn/array/find-index');
entries.unshift('core-js/fn/array/fill');
entries.unshift('core-js/fn/array/from');
entries.unshift('core-js/fn/promise');
entries.unshift('core-js/fn/symbol');
entries.unshift('whatwg-fetch');
entries.unshift('url-search-params-polyfill');
const basePath = 'admin/build';
module.exports = (env, argv) => ({ // eslint-disable-line no-undef
entry: entries,
output: {
path: path.resolve('web'),
filename: basePath + '/[name].[chunkhash].js',
},
devtool: argv.mode === 'development' ? 'eval-source-map' : 'source-map',
plugins: [
new webpack.DefinePlugin({
BUNDLE_ENTRIES_COUNT: entriesCount,
}),
new MiniCssExtractPlugin({
filename: basePath + '/[name].[chunkhash].css',
}),
new ManifestPlugin({
fileName: basePath + '/manifest.json',
}),
new CleanObsoleteChunksPlugin(),
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader',
},
{
test: /\.css/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
],
},
{
test: /\.(scss)$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
camelCase: true,
localIdentName: '[local]--[hash:base64:10]',
},
},
'postcss-loader',
],
},
{
test: /ckeditor5-[^/]+\/theme\/icons\/[^/]+\.svg$/,
use: 'raw-loader',
},
{
test: /\.(svg|ttf|woff|woff2|eot)(\?.*$|$)/,
exclude: /ckeditor5-[^/]+\/theme\/icons\/[^/]+\.svg$/,
use: [
{
loader: 'file-loader',
options: {
name: '/' + basePath + '/fonts/[name].[hash].[ext]',
},
},
],
},
{
test: /\.(jpg|gif|png)(\?.*$|$)/,
use: [
{
loader: 'file-loader',
options: {
name: '/' + basePath + '/images/[name].[hash].[ext]',
},
},
],
},
],
},
});