-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
83 lines (70 loc) · 2.02 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
// This file tells webpack which files to compile and which loaders to use
const path = require('path');
var glob = require('glob');
const globImporter = require('node-sass-glob-importer');
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
// const src_css = 'css/*.css'
const src_js = '**/*.js'
const DEST_FOLDER = '/app/web/themes/contrib/lits_theme/dist'
// relevant directories
const modules = [
'/components/'
]
// -- Gather lits_theme JavaScript and SASS --
var lits_theme_files = [ "/components/style.scss" ]
for (var i of modules) { // collect all of the files
dir = __dirname + i
// add all the js files
lits_theme_files = lits_theme_files.concat(glob.sync(dir + src_js))
}
// -- Gather CKEditor JavaScript and SASS --
// Right now there are no JS files being transpiled for ckeditor5; if that changes you'll need to alter .gitignore
var cke_files = ["/components/02-compounds/ckeditor5/ckeditor5.scss"]
module.exports = {
devtool: 'source-map',
entry: {
lits_theme: lits_theme_files,
ckeditor5: cke_files,
},
output: {
path: path.resolve(__dirname, DEST_FOLDER),
filename: '[name].js',
clean: true, // clear the output folder
},
// include the necessary plugins
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[name].css',
}),
],
stats: 'verbose',
// do the actual transpiling
module: {
rules: [
// javascript
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader']
},
// sass
{
test: /\.s(a|c)ss$/,
exclude: /node_modules/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: "sass-loader",
options: {
sassOptions: {
importer: globImporter(),
verbose: true
}
}
}]
}
]
},
}