-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
84 lines (76 loc) · 2.11 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
81
82
83
84
const webpack = require('webpack');
const path = require('path');
const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const isProduction = process.env.NODE_ENV === 'production';
console.log(isProduction ? 'Production Build' : 'Dev Build');
const plugins = [
new CleanWebpackPlugin(),
new CopyPlugin([
{ from: 'node_modules/@simonwep/pickr/dist/themes', to: 'themes' },
]),
new FixStyleOnlyEntriesPlugin(),
new MiniCssExtractPlugin({
filename: '[name].min.css'
}),
];
if (!isProduction) {
plugins.push(new webpack.SourceMapDevToolPlugin({}));
}
module.exports = {
resolve: {
extensions: ['.js', '.jsx'],
},
entry: {
'../local/reactInit': './src/local/reactInit.js',
'../local/styles': './src/local/styles.scss',
'GradientPicker': './src/js/GradientPicker.jsx',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].min.js',
library: 'react-gpickr',
libraryTarget: 'umd',
publicPath: '/dist/',
umdNamedDefine: true
},
externals: {
// Don't bundle react or react-dom
react: {
commonjs: 'react',
commonjs2: 'react',
amd: 'React',
root: 'React'
},
'react-dom': {
commonjs: 'react-dom',
commonjs2: 'react-dom',
amd: 'ReactDOM',
root: 'ReactDOM'
}
},
devServer: {
contentBase: `${__dirname}/`,
host: '0.0.0.0',
port: 3007
},
module: {
rules: [
{
test: /\.jsx?$/,
use: 'babel-loader'
},
{
test: /\.(scss|css)$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
}
]
},
plugins,
};