-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
106 lines (104 loc) · 2.34 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const config = {
cache: true,
context: path.resolve(__dirname, 'src'),
entry: {
app: './index.jsx',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].bundle.js',
publicPath: "/"
},
resolve: {
extensions: [
'.js',
'.jsx',
'.json',
'.coffee',
'.sass',
'.scss',
'.css',
],
modules: [
path.resolve('src'),
path.resolve('src/js'),
path.resolve('src/sass'),
path.resolve('src/css'),
'node_modules',
],
},
devServer: {
hot: true,
contentBase: path.join(__dirname, './dist'),
compress: true,
historyApiFallback: true,
port: 7000,
stats: {
colors: true,
timings: true,
},
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader?cacheDirectory',
exclude: /node_modules/,
},
{
test: /\.json$/,
loader: 'json-loader',
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader?sourceMap',
}),
},
{
test: /\.(sass|scss)$/,
use: [{
loader: 'style-loader',
}, {
loader: 'css-loader', options: {
sourceMap: true,
},
}, {
loader: 'sass-loader', options: {
sourceMap: true,
},
},],
// use: ['style-loader', 'css-loader', 'sass-loader']
// use: ExtractTextPlugin.extract({
// use: 'css-loader!sass-loader',
// })
},
{
test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
loader: 'file-loader',
},
],
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development'), // eslint-disable-line quote-props
},
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
// new ExtractTextPlugin("css/screen.css"),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
hash: true,
}),
],
};
module.exports = config;