-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
100 lines (97 loc) · 3.2 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
/* eslint-disable flowtype/require-valid-file-annotation */
/* eslint-disable import/no-nodejs-modules*/
const path = require('path');
const CleanObsoleteChunksPlugin = require('webpack-clean-obsolete-chunks');
const webpack = require('webpack');
const glob = require('glob');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const entries = glob.sync(
path.resolve(__dirname, 'src/Sulu/Bundle/*/Resources/js/index.js') // eslint-disable-line no-undef
);
const entriesCount = entries.length;
const basePath = 'adminV2';
entries.unshift('core-js/fn/array/includes');
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');
module.exports = { // eslint-disable-line no-undef
entry: entries,
output: {
path: path.resolve('web'),
filename: basePath + '/[name].[chunkhash].js',
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.(scss)$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
camelCase: true,
localIdentName: '[local]--[hash:base64:10]',
},
},
'postcss-loader',
],
}),
},
{
test: /\.css/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
modules: false,
},
},
],
}),
},
{
test:/\.(jpg|gif|png)(\?.*$|$)/,
use: [
{
loader: 'file-loader',
options: {
name: '/' + basePath + '/images/[name].[hash].[ext]',
},
},
],
},
{
test:/\.(svg|ttf|woff|woff2|eot)(\?.*$|$)/,
use: [
{
loader: 'file-loader',
options: {
name: '/' + basePath + '/fonts/[name].[hash].[ext]',
},
},
],
},
],
},
plugins: [
new CleanObsoleteChunksPlugin(),
new webpack.DefinePlugin({
BUNDLE_ENTRIES_COUNT: entriesCount,
}),
new ManifestPlugin({
fileName: basePath + '/manifest.json',
}),
new ExtractTextPlugin(basePath + '/main.[hash].css'),
],
};