-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
43 lines (41 loc) · 1.58 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
const webpack = require('webpack')
const path = require('path')
const ExtractTextPlugin = require("extract-text-webpack-plugin")
const HtmlWebpackPlugin = require('html-webpack-plugin')
const extractLess = new ExtractTextPlugin({
filename: "index.css"
})
const htmlWebpack = new HtmlWebpackPlugin({
template: `${__dirname}/src/200.html`
})
const nodeEnv = new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
}
})
module.exports = {
entry: './src/main.js',
output: {
path: path.join(__dirname, './build'),
publicPath: '',
filename: 'main.js'
},
plugins: [
extractLess,
htmlWebpack,
nodeEnv
],
module: {
loaders: [
{ test: /\.jsx?$/, exclude: /(node_modules)/, loader: "babel-loader", query: { presets: ['react', 'env']} },
{ test: /\.scss$/, use: extractLess.extract({ use: [ { loader: "css-loader"}, { loader: "sass-loader" } ], fallback: "style-loader" })},
{ test: /\.css$/, use: extractLess.extract({ use: [ { loader: "css-loader", options: { modules: true, sourceMap: true, importLoaders: 1, localIdentName: "[name]--[local]--[hash:base64:8]" }}, { loader: "sass-loader" } ], fallback: "style-loader" })},
{ test: /\.less$/, use: extractLess.extract({ use: [ { loader: "css-loader"}, { loader: "less-loader"} ], fallback: "style-loader" })},
{ test: /\.(eot|woff|woff2|ttf|png|jpe?g|gif)(\?\S*)?$/, loader: 'url?limit=100000&name=[name].[ext]' },
{ test: /\.svg/, use: { loader: 'svg-url-loader', options: {} }}
]
},
devServer: {
historyApiFallback: true
}
}