-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.examples.config.js
67 lines (59 loc) · 1.71 KB
/
webpack.examples.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
var path = require('path');
var fs = require('fs');
var webpack = require('webpack');
var entry = {};
var bannerExcludeFiles = [];
function walk(dir) {
dir = dir || '.'
var directory = path.join(__dirname, '../examples', dir);
fs.readdirSync(directory)
.forEach(function(file) {
var fullpath = path.join(directory, file);
var stat = fs.statSync(fullpath);
var extname = path.extname(fullpath);
if (stat.isFile() && (extname === '.we' || extname === '.vue')) {
var name = path.join('examples', 'build', dir, path.basename(file, extname));
entry[name] = fullpath + '?entry=true';
if (extname === '.we') {
bannerExcludeFiles.push(name + '.js')
}
} else if (stat.isDirectory() && file !== 'build' && file !== 'include') {
var subdir = path.join(dir, file);
walk(subdir);
}
});
}
walk();
var buildBrowserPlugin = 'playground/browser/build/pluginInstall'
var browserPlugin = path.join(__dirname, '../playground/browser/pluginInstall.js')
entry[buildBrowserPlugin] = browserPlugin + '?entry=true';
var banner = '// { "framework": "Vue" }\n'
var bannerPlugin = new webpack.BannerPlugin(banner, {
raw: true,
exclude: bannerExcludeFiles
})
module.exports = {
entry: entry,
output : {
path: '.',
filename: '[name].js'
},
module: {
loaders: [
{
test: /\.(we|vue)(\?[^?]+)?$/,
loader: 'weex'
},
{
test: /\.js(\?[^?]+)?$/,
exclude: /node_modules/,
loader: 'babel-loader?presets[]=es2015',
},
{
test: /\.css(\?[^?]+)?$/,
loader: 'style-loader!css-loader'
}
]
},
plugins: [bannerPlugin]
}