-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathwebpack.config.js
executable file
·72 lines (64 loc) · 1.71 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
/* global __dirname, require, module*/
const webpack = require('webpack');
const ESLintPlugin = require('eslint-webpack-plugin');
const path = require('path');
let libraryName = 'guify';
let plugins = [], outputFile;
module.exports = (env, argv) => {
console.log(`Current mode=${argv.mode}\n`)
if (argv.mode === 'production') { // Uses --mode argument to webpack, or NODE_ENV if not defined.
outputFile = libraryName + '.min.js';
} else if (argv.mode === 'development') {
let linter = new ESLintPlugin();
plugins.push(linter);
outputFile = libraryName + '.js';
} else {
throw new Error(`Invalid development mode ${argv.mode}!`)
}
let config = {
entry: __dirname + '/src/guify.js',
devtool: 'source-map',
output: {
path: __dirname + '/lib',
filename: outputFile,
library: {
type: 'umd',
},
},
module: {
rules: [
{ // Process js files
test: /\.js$/i,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader", "postcss-loader"],
},
// { // Lint all js files with eslint-loader
// test: /(\.jsx|\.js)$/,
// loader: 'eslint-loader',
// exclude: /node_modules/
// }
]
},
resolve: {
modules: [path.resolve('./node_modules'), path.resolve('./src')],
extensions: ['.json', '.js'],
},
plugins: plugins,
devServer: {
compress: true,
port: 9000,
static: {
directory: path.join(__dirname, ''),
serveIndex: true,
},
open: {
target: ['/example'],
}
}
}
return config
}