-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
79 lines (71 loc) · 2.1 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
const path = require('path');
// const MiniCssExtractPlugin = require("mini-css-extract-plugin");
// const HtmlWebpackPlugin = require('html-webpack-plugin');
// const CleanWebpackPlugin = require('clean-webpack-plugin');
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
let config = {
entry: './src/index.js',
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'lib'),
libraryTarget: 'umd'
},
plugins: [
new ExtractTextPlugin('index.css'),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin()
],
module: {
rules: [
{
test: /\.(css|less)$/,
include: [/src/, /example/],
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: ["css-loader?modules&localIdentName=[local]-[hash:base64:5]", "less-loader"]
})
}, {
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader']
}, {
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
externals: {
'react': 'React',
'react-dom': 'ReactDOM',
},
};
if (process.env.MY_NODE_ENV === 'example' || process.env.MY_NODE_ENV === 'exampleBuild') {
config = {
...config,
entry: './example/index.js',
devtool: 'inline-source-map',
devServer: {
contentBase: './docs',
hot: true
},
plugins: [
...config.plugins,
// new CleanWebpackPlugin(['docs']),
// new HtmlWebpackPlugin({
// title: 'Development'
// }),
],
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'docs')
},
resolve: {
alias: {
'scoreboard-react': path.resolve(__dirname,),
}
},
externals:{}
};
}
module.exports = config;