This repository has been archived by the owner on Apr 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathwebpack.config.js
103 lines (96 loc) · 2.52 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
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const prism = require('prismjs');
module.exports = function(env) {
const distEntry = {
'index.js': './src/index.js',
'index.css': './src/index.css'
};
const docsEntry = {
'index.docs.js': './docs/index.js',
'index.docs.css': './docs/index.css'
}
let entry = env.development ? docsEntry : Object.assign(distEntry, docsEntry);
if (env.lib) {
entry = { 'office-ui-fabric.js': './src/lib.js' }
}
let uglifyPlugin = []
if (env.production) {
uglifyPlugin.push(new webpack.optimize.UglifyJsPlugin());
}
return {
context: __dirname,
entry: entry,
output: {
path: env.lib? __dirname + '/lib' : __dirname + '/dist',
filename: '[name]',
publicPath: 'http://localhost:8080/dist',
library: 'OfficeUIFabricVue',
libraryTarget: 'umd'
},
module: {
rules: [
{
test: /\.vue$/,
exclude: path.resolve(__dirname, 'node_modules'),
use: [
'vue-loader',
'eslint-loader'
]
},
{
test: /\.js$/,
exclude: [
path.resolve(__dirname, 'node_modules'),
path.resolve(__dirname, 'lib')
],
use: [
'babel-loader',
'eslint-loader'
]
},
{
test: /\.js$/,
include: path.resolve(__dirname, 'node_modules/office-ui-fabric-js/dist'),
use: ['script-loader']
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
},
{
test: /\.md$/,
use: [
{
loader: 'html-loader'
},
{
loader: 'markdown-loader',
options: {
highlight: function (code, lang) {
if (typeof(lang) == 'undefined') { lang = 'markup'; }
return prism.highlight(code, prism.languages[lang]);
}
}
}
]
}
]
},
plugins: [
...uglifyPlugin,
new webpack.optimize.ModuleConcatenationPlugin(),
new ExtractTextPlugin('[name]'),
// define the vue enviroment.
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(env.production ? 'production' : 'development')
}
})
]
}
}