-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
136 lines (135 loc) · 5.39 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
125
126
127
128
129
130
131
132
133
134
135
136
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = (env, argv) => {
return {
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
new WebpackManifestPlugin({'publicPath': 'bundles/emscore/'}),
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ['**/*', '!static/**'],
}),
new CopyPlugin({
"patterns": [
{from: './assets/images', to: 'images'},
{from: './assets/cke-plugins', to: 'js/cke-plugins'},
{from: './node_modules/ace-builds/src-noconflict', to: 'js/ace'},
{
from: '{config.js,contents.css,styles.js,lang/**/*,plugins/**/*,skins/**/*,vendor/**/*}',
to: 'js/ckeditor',
context: './node_modules/ckeditor4',
}
]
}),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "css/[name].[contenthash].css",
chunkFilename: "[id].css"
}),
],
optimization: {
minimizer: [new TerserPlugin({
extractComments: false,
})],
},
context: path.resolve(__dirname, './'),
entry: {
'black': './assets/skins/black.js',
'black-light': './assets/skins/black-light.js',
'blue': './assets/skins/blue.js',
'blue-light': './assets/skins/blue-light.js',
'green': './assets/skins/green.js',
'green-light': './assets/skins/green-light.js',
'purple': './assets/skins/purple.js',
'purple-light': './assets/skins/purple-light.js',
'red': './assets/skins/red.js',
'red-light': './assets/skins/red-light.js',
'yellow': './assets/skins/yellow.js',
'yellow-light': './assets/skins/yellow-light.js',
'app': './assets/app.js',
'edit-revision': './assets/edit-revision.js',
'managed-alias': './assets/managed-alias.js',
'user-profile': './assets/user-profile.js',
'template': './assets/template.js',
'hierarchical': './assets/hierarchical.js',
'calendar': './assets/calendar.js',
'criteria-view': './assets/criteria-view.js',
'criteria-table': './assets/criteria-table.js',
'i18n': './assets/i18n.js',
'dashboard-browser': './assets/js/module/dashboardBrowser.js',
},
output: {
path: path.resolve(__dirname, 'src/Resources/public'),
filename: 'js/[name].[contenthash].js',
},
resolve: {
fallback: {
"tty": require.resolve("tty-browserify"),
"stream": require.resolve("stream-browserify"),
"buffer": require.resolve("buffer")
}
},
module: {
rules: [
{
test: /\.less$/,
use: [{
loader: MiniCssExtractPlugin.loader,
options: {
// you can specify a publicPath here
// by default it use publicPath in webpackOptions.output
publicPath: '../'
}
}, {
loader: 'css-loader', // translates CSS into CommonJS
options: {
sourceMap: (argv.mode !== 'production')
}
}, {
loader: 'less-loader' // compiles Less to CSS
}]
},
{
test: /\.(sa|sc|c)ss$/,
use: [
{loader: MiniCssExtractPlugin.loader, options: {publicPath: '../'}},
{loader: 'css-loader', options: {sourceMap: (argv.mode !== 'production')}},
{loader: 'sass-loader', options: {sourceMap: (argv.mode !== 'production')}}
],
},
{
test: /\.(png|jpg|gif|svg)$/,
type: 'asset/inline',
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
type: 'asset/resource',
generator: {
filename: 'media/[name][ext]'
}
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
}
}
]
}
}
}