This repository has been archived by the owner on Sep 22, 2023. It is now read-only.
forked from miskreant/rc-slider
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
76 lines (70 loc) · 1.59 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
var webpack = require('webpack');
var path = require('path');
var glob = require('glob');
var cwd = process.cwd();
var pkg = require(path.join(cwd, 'package.json'));
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var plugins = [
new ExtractTextPlugin("slider.css")
];
var entry = path.join(__dirname, './index.js');
function getResolve() {
var alias = {};
var resolve = {
root: cwd,
extensions: ['', '.js', '.jsx'],
alias: alias,
};
var name = pkg.name;
alias[name + '$'] = path.join(cwd, 'index.js');
alias[name] = cwd;
return resolve;
};
module.exports = {
entry: entry,
resolve: getResolve(),
module: {
loaders: [
{
test: /\.jsx$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
// {
// test: /\.css$/,
// exclude: /node_modules/,
// loader: ExtractTextPlugin.extract('css?sourceMap!autoprefixer-loader')
// },
{
test: /\.less$/,
exclude: /node_modules/,
loader: ExtractTextPlugin.extract('css?sourceMap!autoprefixer-loader!less?sourceMap')
}
],
},
output: {
library: 'Slider',
libraryTarget: 'umd',
path: 'dist',
filename: 'slider.js',
},
// This is key. https://gist.github.com/STRML/2117f574726bdf0b8d58
externals: {
react: {
root: 'React',
commonjs: 'react',
commonjs2: 'react',
amd: 'react',
},
'react-dom': {
root: 'ReactDOM',
commonjs: 'react-dom',
commonjs2: 'react-dom',
amd: 'react-dom',
},
},
node: {
Buffer: false
},
plugins: plugins
};