forked from sulu/sulu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
124 lines (120 loc) · 4.18 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* 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 {styles} = require('@ckeditor/ckeditor5-dev-utils'); // eslint-disable-line import/no-extraneous-dependencies
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('public'),
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/,
exclude: /ckeditor5-[^/]+\/theme\/[\w-/]+\.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: /ckeditor5-[^/]+\/theme\/[\w-/]+\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
},
{
loader: 'postcss-loader',
options: styles.getPostCssConfig({
themeImporter: {
themePath: require.resolve('@ckeditor/ckeditor5-theme-lark'),
},
minify: true,
}),
},
],
},
{
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]',
},
},
],
},
],
},
});