-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
96 lines (89 loc) · 2.37 KB
/
webpack.config.babel.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
85
86
87
88
89
90
91
92
93
94
95
96
import NpmInstallWebpackPlugin from 'npm-install-webpack-plugin';
import webpack from 'webpack';
import merge from 'webpack-merge';
import path from 'path';
import isDev from 'isdev';
import autoprefixer from 'autoprefixer';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import { Dir } from './server/config';
const TARGET = process.env.npm_lifecycle_event;
const sassNeatPaths = require('node-neat').with([
path.resolve(__dirname, './app/sass/assets/sass')
]).map(neatPath => 'includePaths[]=' + neatPath).join('&');
let Config = {
entry: [
'babel-polyfill',
path.join(Dir.app, 'index.jsx'),
],
output: {
path: path.join(Dir.public, 'build'),
filename: 'bundle.js',
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
],
module: {
preLoaders: [{
test: /\.jsx?$/,
loader: 'eslint-loader',
exclude: /node_modules/,
include: Dir.src,
}],
loaders: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
}, {
test: /\.json$/,
loader: 'json'
}, {
test: /(\.scss|\.css)$/,
loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass?sourceMap&' + sassNeatPaths),
}, {
test: /\.svg$/,
loader: 'file-loader',
}, {
test: /\.(png|jpg|gif|ico)$/,
loader: 'url?limit=25000',
},
],
},
resolve: {
root: Dir.src,
extensions: ['', '.js', '.jsx', '.json', '.scss'],
},
postcss: [autoprefixer],
plugins: [
new ExtractTextPlugin('style.css', { allChunks: true }), // compiled css (single file only)
],
};
if (TARGET === 'build' && !isDev) {
Config = merge(Config, {
bail: true,
devtool: 'source-map',
output: { publicPath: '/build/' },
plugins: [
new webpack.optimize.UglifyJsPlugin({
comments: false,
dropDebugger: true,
dropConsole: true,
compressor: {
warnings: false,
},
}),
],
});
}
if (TARGET === 'server:dev' && isDev) {
Config = merge(Config, {
devtool: 'eval',
entry: ['webpack-hot-middleware/client'],
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new NpmInstallWebpackPlugin({ save: true }),
],
});
}
export default Config;