This repository has been archived by the owner on Sep 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathwebpack.common.js
58 lines (57 loc) · 1.61 KB
/
webpack.common.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
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
const exclude = '/node_modules';
module.exports = {
entry: './app/app.js',
output: {
filename: '[hash].js',
path: path.join(__dirname, 'dist'),
publicPath: '/'
},
module: {
rules: [
{
test: /\.js$/,
exclude: exclude,
use: 'babel-loader'
},
{
test: /\.(css|less)$/,
exclude: exclude,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
'css-loader?sourceMap',
'postcss-loader?sourceMap',
'less-loader?sourceMap'
]
})
},
{
test: /\.(svg|jpg|jpeg|png|pdf|xml|ico|json|txt)$/,
exclude: exclude,
use: 'file-loader'
},
{
test: /\.(eot|ttf|woff|woff2)$/,
exclude: exclude,
use: 'file-loader'
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': `"${process.env.NODE_ENV}"`
}),
new ExtractTextPlugin({
filename: 'app.css',
disable: false,
allChunks: true
}),
new HtmlWebpackPlugin({
template: './app/index.html'
})
]
};