forked from owncloud/web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
108 lines (102 loc) · 2.84 KB
/
webpack.common.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
const path = require('path');
const fs = require('fs')
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const WebpackCopyPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require ('html-webpack-plugin')
const appFolder = path.resolve(__dirname, 'apps')
let apps = []
let favicon = './themes/owncloud/assets/gfx/favicon.jpg'
if(fs.existsSync('config.json')) {
var config = require('./config.json')
}else{
var config = require('./tests/drone/config.json')
}
if(fs.existsSync(`./themes/${config.theme}/assets/gfx/favicon.jpg`)) {
favicon = `./themes/${config.theme}/assets/gfx/favicon.jpg`
}
config.apps
.forEach(function (mod) {
if(fs.existsSync(path.resolve(appFolder, mod))){
var modPath = {
from: path.resolve('apps', mod ,'dist'),
to: path.resolve(__dirname, 'dist', 'apps', mod)
}
apps.push(modPath)
}
})
const src_files = [{
from: path.resolve(__dirname, 'themes/**'),
to: path.resolve(__dirname, 'dist')
},{
from: path.resolve(__dirname, 'node_modules', 'requirejs', 'require.js'),
to: path.resolve(__dirname, 'dist', 'node_modules', 'requirejs')
}]
for(file of src_files){
apps.push(file)
}
module.exports = {
plugins: [
new WebpackCopyPlugin(apps),
new HtmlWebpackPlugin({
template: 'index.html',
favicon: favicon
}),
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "css/[name].css",
chunkFilename: "css/[name].[id].css"
})
],
entry: {
core: [
'./src/default.js',
'./node_modules/material-design-icons-iconfont/dist/material-design-icons.css',
'./node_modules/vuetify/dist/vuetify.css',
'./static/fonts/ocft/css/ocft.css']
},
output: {
filename: 'core/[name].bundle.js',
chunkFilename: 'core/[name].[id].bundle.js'
},
module: {
rules: [
{
test: /\.js?$/,
exclude: [/node_modules/, /apps/],
include: [/src/]
}, {
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
include: [/node_modules\/material-design-icons-iconfont\/dist/, /static\/fonts\/ocft\/font/],
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
publicPath: '../fonts',
outputPath: 'fonts'
}
}]
}, {
enforce: 'pre',
test: /\.(js|vue)$/,
exclude: /node_modules/,
loader: "eslint-loader",
},{
test: /\.vue$/,
loader: 'vue-loader',
exclude: [/node_modules/]
}, {
test: /\.(sa|sc|c)ss$/,
include: [/node_modules/,/src/, /static/],
use: [
"style-loader",
MiniCssExtractPlugin.loader,
"css-loader",
"sass-loader"
]
}
]
}
};