12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- /**
- * Created by magedu on 2017/4/20.
- */
- const path = require('path');
- const webpack = require('webpack');
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- module.exports = {
- devtool: 'source-map',
- entry: {
- 'app': [
- './src/index'
- ]
- },
- output: {
- path: path.join(__dirname, 'dist'),
- filename: '[name]-[hash:8].js',
- publicPath: '/assets/'
- },
- resolve: {
- extensions: ['.js']
- },
- module: {
- rules: [
- {
- test: /\.js$/,
- exclude: /node_modules/, // 不编译第三方包
- use: [
- { loader: 'react-hot-loader/webpack' },
- { loader: 'babel-loader' }
- ]
- },
- {
- test: /\.less$/,
- use: [
- { loader: "style-loader" },
- { loader: "css-loader" },
- { loader: "less-loader" }
- ]
- }
- ]
- },
- plugins: [
- new webpack.optimize.OccurrenceOrderPlugin(true),
- new webpack.DefinePlugin({ 'process.env': { NODE_ENV: JSON.stringify('production') } }),
- new webpack.optimize.UglifyJsPlugin({
- compress: {
- warnings: false
- },
- sourceMap: true
- }),
- new HtmlWebpackPlugin({
- template: 'src/index.html',
- inject: true
- })
- ]
- };
|