forked from javaBin/javazone.no
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
56 lines (46 loc) · 1.72 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
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var autoprefixer = require('autoprefixer');
var webpack = require('webpack');
var path = require('path');
var exclude = /node_modules/;
var output = path.join(__dirname, 'dist');
var node_env = process.env.NODE_ENV || 'development';
const isDev = node_env === 'development';
const babelLoader = 'babel-loader?presets[]=es2015,presets[]=react,plugins[]=transform-react-require,plugins[]=transform-object-assign';
const styleLoader = 'css-loader?sourceMap!postcss-loader!less-loader?sourceMap';
const config = {
entry: './app/app.js',
output: {
filename: 'app.js',
path: output
},
module: {
loaders: [
{ test: /\.js$/, exclude: exclude, loader: babelLoader},
{ test: /\.less$/, exclude: exclude, loader: ExtractTextPlugin.extract('style-loader', styleLoader)},
{ test: /\.(svg|jpg|jpeg|png|pdf|xml|ico|json|txt)$/, exclude: exclude, loader: 'file?name=/assets/[path][name].[ext]'},
{ test: /\.(eot|ttf|woff|woff2)$/, exclude: exclude, loader: 'file?name=assets/fonts/[name].[ext]'}
]
},
plugins: [
new webpack.DefinePlugin({'process.env.NODE_ENV': `"${node_env}"`}),
new ExtractTextPlugin('app.css'),
new HtmlWebpackPlugin({
template: './app/index.html'
})
],
devServer: {
historyApiFallback: true,
progress: true
},
postcss: function() {
return [autoprefixer({browsers: ['last 2 versions']})];
}
};
if (isDev) {
config.devTool = 'eval';
} else {
config.plugins.push(new webpack.optimize.UglifyJsPlugin());
}
module.exports = config