-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.mix.js
164 lines (134 loc) · 4.47 KB
/
webpack.mix.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const mix = require('laravel-mix')
require('laravel-vue-lang/mix')
// require('laravel-mix-imagemin')
// const imageminMozjpeg = require('imagemin-mozjpeg')
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
*/
mix.lang()
mix.js('resources/js/app.js', 'public/js').vue({ version: 2 })
.sourceMaps(true, 'inline-source-map')
.version()
/*
mix.imagemin({
from: 'images/*',
}, {
context: 'resources',
},{
optipng: {
optimizationLevel: 3
},
jpegtran: null,
plugins: [
imageminMozjpeg({
quality: 75,
progressive: true,
}),
],
})
*/
mix.copy('./resources/images/*', 'public/images')
mix.sass('resources/sass/app.sass', 'public/css')
.version()
mix.styles([
// Bootstrap
// 'node_modules/bootstrap/dist/css/bootstrap.css',
// Selectize
'node_modules/selectize/dist/css/selectize.css',
// Icon fonts
'node_modules/font-awesome/css/font-awesome.css',
'node_modules/material-design-iconic-font/dist/css/material-design-iconic-font.css',
// DataTables
// 'node_modules/datatables.net-dt/css/jquery.dataTables.css',
'node_modules/datatables.net-bs4/css/dataTables.bootstrap4.css',
// Bootstrap-select
'node_modules/bootstrap-select/dist/css/bootstrap-select.css',
], 'public/css/vendor.css')
mix.version([
'public/css/vendor.css',
// 'public/js/vendor.js',
])
// mix.copy('node_modules/bootstrap/fonts', 'public/fonts');
mix.copy('node_modules/font-awesome/fonts', 'public/fonts')
mix.copy('node_modules/material-design-iconic-font/dist/fonts', 'public/fonts')
mix.copy('node_modules/datatables.net-dt/images/*', 'public/images')
mix.copy('node_modules/datatables.net-plugins/i18n/no-NB.json', 'public/misc/datatables-nb.json')
mix.copy('node_modules/openseadragon/build/openseadragon/images/*', 'public/images')
/*
|--------------------------------------------------------------------------
| And then some horrible CKEditor mess
| https://github.com/ckeditor/ckeditor5-vue/issues/23#issuecomment-455756667
|--------------------------------------------------------------------------
*/
const { CKEditorTranslationsPlugin } = require("@ckeditor/ckeditor5-dev-translations");
const { styles } = require('@ckeditor/ckeditor5-dev-utils')
// make sure you copy these two regexes from the CKEdidtor docs:
// https://ckeditor.com/docs/ckeditor5/latest/installation/advanced/alternative-setups/integrating-from-source.html#webpack-configuration
const CKERegex = {
svg: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
css: /ckeditor5-[^/\\]+[/\\]theme[/\\].+\.css$/,
}
Mix.listen('configReady', webpackConfig => {
const rules = webpackConfig.module.rules
// these change often! Make sure you copy the correct regexes for your Webpack version!
const targetSVG = /(\.(png|jpe?g|gif|webp|avif)$|^((?!font).)*\.svg$)/
const targetFont = /(\.(woff2?|ttf|eot|otf)$|font.*\.svg$)/
const targetCSS = /\.p?css$/
// exclude CKE regex from mix's default rules
for (const rule of rules) {
// console.log(rule.test) // uncomment to check the CURRENT rules
if (rule.test.toString() === targetSVG.toString()) {
rule.exclude = CKERegex.svg
} else if (rule.test.toString() === targetFont.toString()) {
rule.exclude = CKERegex.svg
} else if (rule.test.toString() === targetCSS.toString()) {
rule.exclude = CKERegex.css
}
}
})
mix.webpackConfig({
plugins: [
new CKEditorTranslationsPlugin({
language: "nb",
addMainLanguageTranslationsToAllAssets: true,
}),
],
module: {
rules: [
{
test: CKERegex.svg,
use: ["raw-loader"],
},
{
test: CKERegex.css,
use: [
{
loader: "style-loader",
options: {
injectType: "singletonStyleTag",
attributes: {
"data-cke": true,
},
},
},
"css-loader", // ADDED
{
loader: "postcss-loader",
options: {
postcssOptions: styles.getPostCssConfig({
// moved into option `postcssOptions`
themeImporter: {
themePath: require.resolve("@ckeditor/ckeditor5-theme-lark"),
},
minify: true,
}),
},
},
],
},
],
},
});