-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.babel.js
79 lines (76 loc) · 1.87 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
import pkg from './package.json';
import path from 'path';
import autoprefixer from 'autoprefixer';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import CleanWebpackPlugin from 'clean-webpack-plugin';
import { optimize, BannerPlugin } from 'webpack';
const sassLoaders = [
'css?sourceMap',
'sass?sourceMap',
'postcss-loader?pack=cleaner'
];
const bannerTemplate = [
`${pkg.name} - ${pkg.homepage}`,
`Version: ${pkg.version}`,
`Author: ${pkg.author}`
].join('\n');
module.exports = {
entry: {
mimodal: './src/js/main.js'
},
output: {
path: path.join(__dirname, 'dist'),
publicPath: 'dist/',
filename: '[name].js'
},
module: {
preLoaders: [{
test: /\.js?$/,
loaders: ['eslint'],
include: 'src/js/'
}],
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015'],
plugins: ['transform-runtime']
}
}, {
test: /\.scss$/,
loaders: ['style', 'css?sourceMap', 'sass?sourceMap'],
loader: ExtractTextPlugin.extract('style', sassLoaders.join('!'))
}]
},
// devtool: 'source-map',
plugins: [
new CleanWebpackPlugin(['dist', 'public/js/mimodal.js', 'public/css/mimodal.css']),
new ExtractTextPlugin('[name].css'),
new optimize.DedupePlugin(),
new BannerPlugin(bannerTemplate),
new optimize.UglifyJsPlugin({
compress: { warnings: false }
})
],
sassLoader: {
includePaths: [path.resolve(__dirname, './src/sass')]
},
postcss: function() {
return {
defaults: [autoprefixer],
cleaner: [autoprefixer({ browsers: ['last 2 versions'] })]
};
},
resolve: {
extensions: ['', '.js', '.scss'],
modulesDirectories: ['src', 'node_modules']
},
devServer: {
hot: true,
contentBase: 'public/',
progress: true,
colors: true,
noInfo: true
}
};