-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
webpack.config.js
80 lines (74 loc) · 1.99 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
/* global __dirname, require, module */
'use strict'
const webpack = require('webpack')
const path = require('path')
const env = require('yargs').argv.env
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const extractSass = new ExtractTextPlugin({filename: 'noty.css'})
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin
const BrowserSyncPlugin = require('browser-sync-webpack-plugin')
let libraryName = 'Noty'
let plugins = []
let outputFile
plugins.push(extractSass)
plugins.push(new webpack.DefinePlugin({
VERSION: JSON.stringify(require('./package.json').version)
}))
if (env === 'build') {
plugins.push(new UglifyJsPlugin({minimize: true, sourceMap: true}))
outputFile = libraryName.toLowerCase() + '.min.js'
} else {
outputFile = libraryName.toLowerCase() + '.js'
plugins.push(new BrowserSyncPlugin({
ui: false,
host: 'localhost',
port: 3000,
server: {
baseDir: ['./'],
index: 'demo/index.html'
}
}))
}
const config = {
entry: path.join(__dirname, '/src/index.js'),
devtool: 'source-map',
output: {
path: path.join(__dirname, '/lib'),
filename: outputFile,
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
rules: [
{
// standard-loader as a preloader
enforce: 'pre',
test: /\.js?$/,
loader: 'standard-loader',
exclude: /(node_modules|bower_components)/,
options: {
error: false,
snazzy: true,
parser: 'babel-eslint'
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/
},
{
test: /\.scss$/,
use: extractSass.extract(['css-loader', 'postcss-loader', 'sass-loader']),
exclude: /(node_modules|bower_components)/
}
]
},
resolve: {
modules: [path.resolve('./src'), path.resolve('./node_modules')],
extensions: ['.js', '.scss']
},
plugins: plugins
}
module.exports = config