-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
133 lines (129 loc) · 3.45 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// webpack.config.js
const CleanWebpackPlugin = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
//const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const myPackage = process.env.npm_config_myPackage;
const sassBuild = process.env.npm_config_sassBuild;
//npm run dev --myPackage=cwc-chart-datatypes
const entryPointsObj = {
'cat-components': __dirname + '/packages/index.js'
// 'cwc-applicationtime/applicationtime': __dirname + '/packages/cwc-applicationtime/cwc-applicationtime.js',
// 'cwc-chart-datatypes/index': __dirname + '/packages/cwc-chart-datatypes/cwc-chart-datatypes.js'
};
const sassEntryPoints = {
'cwc-charts/cwc-charts': __dirname + '/packages/cwc-charts/cwc-charts.scss',
'cwc-chart-datatypes/cwc-chart-datatypes': __dirname + '/packages/cwc-chart-datatypes/cwc-chart-datatypes.scss'
}
let entryPoints = {},
pathsToClean,
// the clean options to use
cleanOptions = {
root: path.resolve(__dirname),
verbose: true,
dry: false
};
if (myPackage) {
pathsToClean = 'dist/' + myPackage + '/';
Object.keys(entryPointsObj).forEach(function (key) {
let objKey = key;
if (entryPointsObj[key].indexOf(myPackage) > -1) {
let objValue = entryPointsObj[key];
// the clean options to use
return entryPoints[objKey] = objValue;
}
});
} else {
entryPoints = entryPointsObj;
pathsToClean = 'dist/';
}
module.exports = {
entry: ["./src/core-chart-datatypes/core-chart-datatypes.js"],
watch: false,
mode: 'none',
//devtool: 'source-map',
output: {
path: (sassBuild) ? path.resolve(__dirname, 'packages') : path.resolve(__dirname, 'dist'),
filename: (sassBuild) ? '[name].css' : '[name].js'
},
resolve: {
// resolve file extensions
extensions: ['.js', '.scss']
},
module: {
rules: [{
test: /\.(scss)$/,
loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader'])
},
{
test: /\.html$/,
use: [{
loader: 'babel-loader',
options: {
presets: ['env'],
plugins: ['syntax-dynamic-import']
}
},
{
loader: 'polymer-webpack-loader'
}
]
},
{
test: /\.js$/,
use: [{
loader: 'babel-loader',
options: {
presets: ['env']
}
}]
}
]
},
/*optimization:{
minimizer:[
new UglifyJsPlugin({
uglifyOptions:{
test: /\.js(\?.*)?$/i,
warnings: false,
parse:{},
compress:{},
mangle:true,
toplevel:false,
nameCache: null,
ie8: false,
keepfnames: false,
output:{
comments: false
}
}
})
]
},*/
plugins: [
new CleanWebpackPlugin(pathsToClean, cleanOptions),
// Specify output file name and path
new ExtractTextPlugin({
filename: '[name].css',
allChunks: false
}),
/*new UglifyJsPlugin({
uglifyOptions:{
output:{
comments: false
},
compress: {
warnings: false
}
}
})*/
/*new HtmlWebpackPlugin({
template: './demo/template.html',
inject: 'head',
hash: true,
filename: "../demo/index.html"
})*/
]
};