forked from 1rosehip/jplist-es6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.es6.js
84 lines (74 loc) · 2.68 KB
/
webpack.config.es6.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
const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
//const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const copy = require('./build/webpack-copy-plugin/plugin');
//handle source version
const pjson = fs.readFileSync('./package.json', 'utf8');
let version = JSON.parse(pjson).version;
for(let arg of process.argv){
if(arg.indexOf('--version=') !== -1){
version = arg.replace('--version=', '').trim();
}
}
const config = {
entry: {
'jplist-es6': path.resolve(__dirname, 'src/' + version + '/index.js')
},
output: {
//filename: 'jplist.min.js',
filename: '[name].min.js',
path: path.resolve(__dirname, 'dist/' + version)
},
mode: 'production', //development, production
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: { minimize: false }
},
{
loader: 'postcss-loader',
options: {
minimize: false,
plugins: (loader) => [
require('postcss-import')({ root: loader.resourcePath }),
require('postcss-cssnext')({warnForDuplicates: false}),
require('postcss-nested')(),
require('postcss-simple-vars')(),
require('autoprefixer')(),
require('postcss-prettify')(),
//require('cssnano')({zindex: false})
]
}
}
]
})
}
]
},
//https://webpack.js.org/configuration/devtool/
devtool: 'source-map',
plugins: [
//new CleanWebpackPlugin(['dist']),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production') //development, production
}),
//https://webpack.js.org/plugins/extract-text-webpack-plugin/
new ExtractTextPlugin('jplist.styles.css'),
new copy()
],
//https://webpack.js.org/configuration/stats/
//stats: 'minimal' //'errors-only'
stats: {
entrypoints: false,
modules: false
}
};
module.exports = config;