-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
110 lines (109 loc) · 3.49 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
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const ConcatPlugin = require('webpack-concat-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
entry: {
vendors: './phpmyfaq/assets/src/vendors.js',
frontend: './phpmyfaq/assets/src/frontend.js',
backend: './phpmyfaq/admin/assets/src/index.js',
styles: './phpmyfaq/assets/themes/default/scss/style.scss',
'admin-styles': './phpmyfaq/admin/assets/scss/style.scss',
},
plugins: [
new CleanWebpackPlugin(),
new CopyPlugin([
{
from: 'node_modules/tinymce/tinymce.min.js',
to: path.resolve(__dirname, 'phpmyfaq/admin/assets/js/editor/tinymce.min.js'),
},
{
from: 'node_modules/tinymce/plugins/',
to: path.resolve(__dirname, 'phpmyfaq/admin/assets/js/editor/plugins/'),
},
{
from: 'node_modules/tinymce/skins/',
to: path.resolve(__dirname, 'phpmyfaq/admin/assets/js/editor/skins/'),
},
{
from: 'node_modules/tinymce/themes/',
to: path.resolve(__dirname, 'phpmyfaq/admin/assets/js/editor/themes/'),
},
{
from: 'node_modules/highlight.js/lib/highlight.js',
to: path.resolve(__dirname, 'phpmyfaq/assets/js/libs'),
},
{
from: 'node_modules/highlight.js/styles/default.css',
to: path.resolve(__dirname, 'phpmyfaq/assets/js/libs'),
},
]),
new ConcatPlugin({
uglify: true,
fileName: 'phpmyfaq.js',
filesToConcat: [
path.resolve(__dirname, 'phpmyfaq/assets/src/add.js'),
path.resolve(__dirname, 'phpmyfaq/assets/src/category.js'),
path.resolve(__dirname, 'phpmyfaq/assets/src/comments.js'),
path.resolve(__dirname, 'phpmyfaq/assets/src/editor.js'),
path.resolve(__dirname, 'phpmyfaq/assets/src/faq.js'),
path.resolve(__dirname, 'phpmyfaq/assets/src/records.js'),
path.resolve(__dirname, 'phpmyfaq/assets/src/typeahead.js'),
path.resolve(__dirname, 'phpmyfaq/assets/src/functions.js'),
path.resolve(__dirname, 'phpmyfaq/assets/src/setup.js'),
],
}),
/**
* Concat TinyMCE plugin and uglify it
*/
new ConcatPlugin({
uglify: true,
outputPath: '../../../',
fileName: 'phpmyfaq/admin/assets/js/editor/plugins/phpmyfaq/plugin.min.js',
filesToConcat: [path.resolve(__dirname, 'phpmyfaq/admin/assets/js/phpmyfaq.tinymce.plugin.js')],
}),
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
filesToConcat: [],
}),
],
output: {
path: path.resolve(__dirname, 'phpmyfaq/assets/dist'),
},
mode: 'production',
module: {
rules: [
{
test: /\.scss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: (resourcePath, context) => {
return path.relative(path.dirname(resourcePath), context) + '/assets/dist/';
},
outputPath: 'css/',
},
},
'css-loader',
'sass-loader',
],
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
publicPath: './fonts/',
},
},
],
},
],
},
};