-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
53 lines (47 loc) · 1.02 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
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const distPath = path.join(__dirname, './docs');
const docsPath = path.join(__dirname, './demo');
const srcPath = path.join(__dirname, './src');
const rules = [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader']
})
}
];
const entry = {
docs: path.join(docsPath, 'index.js')
}
const plugins = [
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new HtmlWebpackPlugin({
template: path.join(docsPath, 'index.html'),
path: distPath,
filename: 'index.html',
}),
new ExtractTextPlugin({filename: 'style.css'})
]
module.exports = {
entry,
output: {
path: distPath,
filename: '[name].js',
},
module: {
rules
},
plugins
};