-
Notifications
You must be signed in to change notification settings - Fork 301
Expand file tree
/
Copy pathwebpack.config.js
More file actions
executable file
·74 lines (65 loc) · 1.62 KB
/
webpack.config.js
File metadata and controls
executable file
·74 lines (65 loc) · 1.62 KB
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
const webpack = require('webpack')
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const UnminifiedWebpackPlugin = require('unminified-webpack-plugin')
const libraryName = 'ScrollTrigger'
let plugins = [new UnminifiedWebpackPlugin()]
let mode = 'development'
let entry = __dirname + '/src/ScrollTrigger.js'
let outputFile = libraryName + '.js?[hash]'
let outputPath = __dirname + '/dist'
let contentBase = 'dev'
switch (process.env.NODE_ENV) {
case 'demo':
entry = __dirname + '/demo/main.js'
outputPath = __dirname + '/public'
contentBase = 'demo'
plugins.push(new HtmlWebpackPlugin({
inject: 'body',
template: 'demo/index.html'
}))
break
case 'development':
entry = __dirname + '/dev/main.js'
plugins.push(new HtmlWebpackPlugin({
inject: 'body',
template: 'dev/index.html'
}))
break
default:
outputFile = libraryName + '.min.js'
mode = 'production'
break
}
module.exports = {
entry: entry,
mode: mode,
devtool: 'source-map',
output: {
path: outputPath,
filename: outputFile,
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
plugins: plugins,
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
},
devServer: {
static: contentBase,
host: '127.0.0.1',
port: 8010
}
}