-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwebpack.config.js
More file actions
65 lines (60 loc) · 1.62 KB
/
webpack.config.js
File metadata and controls
65 lines (60 loc) · 1.62 KB
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
const path = require('path');
const webpack = require('webpack');
const BundleTracker = require('webpack-bundle-tracker');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
context: __dirname,
entry: {
main: './static/js/main.js',
style: './static/css/main.less'
},
output: {
path: path.resolve('./static/bundles/'),
filename: '[name].js',
},
plugins: [
new BundleTracker({ filename: './webpack-stats.json' }),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
}),
new ExtractTextPlugin('styles.css'),
],
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
plugins: [
'transform-runtime',
'transform-react-remove-prop-types',
'transform-react-constant-elements',
'transform-react-inline-elements',
],
presets: ['es2015', 'react'],
}
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({fallback: "style-loader", use: "css-loader"})
},
{
test: /\.less$/,
loader: ExtractTextPlugin.extract({fallback: "style-loader", use: "css-loader!less-loader"})
},
{
// I want to uglify with mangling only app files, not thirdparty libs
test: /.*\/main\/.*\.js$/,
exclude: /.spec.js/, // excluding .spec files
loader: "uglify"
},
],
},
resolve: {
modules: ['node_modules', 'bower_components'],
extensions: ['.js', '.jsx'],
},
};