-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
50 lines (50 loc) 路 1.52 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
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const cssModules = 'modules&importLoaders=1&localIdentName=[name]__[local]__[hash:base64:5]'
module.exports = {
resolve: {
extensions: ['.js', '.jsx', '.css']
},
entry: './src/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'bundle.js',
publicPath: '/'
},
module: {
rules: [
{ test: /(\.js|jsx)$/, exclude: /node_modules/, loaders: ['babel-loader'] },
{ test: /\.css$/, loader: `style-loader!css-loader?${cssModules}` },
{
test: /\.scss$/,
exclude: /node_modules/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader?modules&importLoader=2&sourceMap&localIdentName=[name]__[local]___[hash:base64:5]!sass-loader'
})
},
{
test: /\.less$/,
use: [{
loader: 'style-loader' // creates style nodes from JS strings
}, {
loader: 'css-loader' // translates CSS into CommonJS
}, {
loader: 'less-loader' // compiles Less to CSS
}]
},
{ test: /\.(jpe?g|png|gif|ico)$/i, loader: 'file?name=[name].[ext]' }
]
},
devServer: {
historyApiFallback: true,
port: 3000
},
plugins: [
new HtmlWebpackPlugin({
template: './src/assets/index.html',
favicon: './src/assets/favicon.ico' }),
new ExtractTextPlugin('style.css', { allChunks: true })
]
}