-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·86 lines (85 loc) · 2.35 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
77
78
79
80
81
82
83
84
85
86
const path = require('path');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const pxtorem = require('postcss-pxtorem');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const StyleLintPlugin = require('stylelint-webpack-plugin');
module.exports = {
entry: ['babel-polyfill', './assets/react/app.js'],
output: {
path: path.resolve(__dirname, 'public/_build/'),
publicPath: '/_build/',
filename: 'bundle.js',
},
devServer: {
contentBase: 'public',
historyApiFallback: true,
},
module: {
rules: [
{
test: /\.scss$/,
include: path.join(__dirname, 'assets'),
use: ExtractTextPlugin.extract({
fallback: [{
loader: 'style-loader',
}],
use: [
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
localIdentName: '[path]___[name]__[local]___[hash:base64:5',
},
},
{
loader: 'postcss-loader',
},
{
loader: 'sass-loader',
},
],
}),
},
{
enforce: 'pre',
test: /\.js$/,
include: path.join(__dirname, 'assets/react'),
loaders: ['eslint-loader'],
},
{
test: /\.js$/,
include: path.join(__dirname, 'assets/react'),
loaders: ['babel-loader?cacheDirectory'],
},
{ test: /\.eot(\?v=\d+.\d+.\d+)?$/, use: 'file-loader' },
{ test: /\.(woff|woff2)$/, use: 'file-loader?prefix=font/&limit=5000' },
{ test: /\.ttf(\?v=\d+.\d+.\d+)?$/, use: 'file-loader?limit=10000&mimetype=application/octet-stream' },
{ test: /\.svg(\?v=\d+.\d+.\d+)?$/, use: 'file-loader?limit=10000&mimetype=image/svg+xml' },
{ test: /\.(jpe?g|png|gif)$/i, use: 'file-loader' },
{ test: /\.ico$/, use: 'file-loader?name=[name].[ext]' },
],
},
plugins: [
new ExtractTextPlugin({
filename: 'app.css',
allChunks: true,
}),
new StyleLintPlugin({
files: ['**/*.s?(a|c)ss'],
syntax: 'scss',
}),
new webpack.LoaderOptionsPlugin({
options: {
postcss: [
autoprefixer('last 2 versions'),
pxtorem(),
],
},
}),
],
watchOptions: {
poll: true,
},
};