This repository has been archived by the owner on Feb 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
/
webpack.dev.config.js
100 lines (94 loc) · 2.46 KB
/
webpack.dev.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
var path = require('path');
var webpack = require('webpack');
var StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');
var env = process.env.WEBPACK_BUILD || 'development';
var CleanWebpackPlugin = require('clean-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var webpackDevConfig = require('./webpack.base.config')('development');
var webpackProdConfig = require('./webpack.base.config')('production');
var paths = [
'/',
'/components/',
'/components/validators/',
'/components/checkboxes/',
'/components/avform/',
'/404.html',
];
var basepath = env === 'production' ? process.env.BASEPATH || '/availity-reactstrap-validation/' : '/';
var config = [{
devtool: 'source-map',
devServer: {
contentBase: './build',
stats: {
chunks: false,
},
},
entry: {
main: './docs/lib/app.js',
},
node: {
fs: 'empty',
},
output: {
filename: 'bundle.js',
publicPath: basepath,
path: './build',
libraryTarget: 'umd',
},
plugins: [
new CleanWebpackPlugin(['build']),
new CopyWebpackPlugin([{ from: './docs/static', to: 'assets' }]),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(env),
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new StaticSiteGeneratorPlugin('main', paths, {basename: basepath}),
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('/assets/style.css'),
],
module: {
loaders: [
{
test: /\.(json)$/,
loaders: [
'json-loader?cacheDirectory',
],
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loaders: [
'babel-loader?cacheDirectory',
],
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader'),
},
],
},
resolve: {
extensions: ['', '.js', '.jsx', '.json'],
alias: {
'bootstrap-css': path.join(__dirname,'node_modules/bootstrap/dist/css/bootstrap.css'),
'availity-reactstrap-validation': path.resolve('./src'),
},
},
}];
if (env === 'development') {
config.push(webpackDevConfig);
config.push(webpackProdConfig);
} else {
config[0].plugins.push(new webpack.optimize.UglifyJsPlugin(
{
minimize: true,
compress: {
warnings: false,
},
mangle: true,
}
));
}
module.exports = config;