123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- const path = require('path')
- const ip = require('ip')
- const webpack = require('webpack')
- const HtmlWebpackPlugin = require('html-webpack-plugin')
- const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin')
- const config = require('../config')
- const clientOptions = '?path=/__what&timeout=5000&reload=true&quiet=true'
- const VueLoaderPlugin = require('vue-loader/lib/plugin')
- module.exports = {
- mode: 'development',
- entry: [
- `webpack-hot-middleware/client${clientOptions}`,
- path.resolve(__dirname, '../../src/index.js'),
- ],
- output: {
- filename: 'bundle.js',
- publicPath: config.dev.publicPath,
- },
- module: {
- rules: [
- {
- test: /\.css$/i,
- use: [
- 'style-loader',
- {
- loader: 'css-loader',
- options: {
- importLoaders: 1,
- },
- },
- 'postcss-loader',
- ],
- },
- {
- test: /\.s[ac]ss$/i,
- use: [
- 'style-loader',
- {
- loader: 'css-loader',
- options: {
- importLoaders: 2,
- },
- },
- 'postcss-loader',
- 'sass-loader',
- ],
- },
- {
- test: /\.(png|jpe?g|gif|svg)$/i,
- loader: 'file-loader',
- },
- {
- test: /\.(ttf|otf|woff2?|eot)$/i,
- loader: 'file-loader',
- },
- {
- test: /\.(mp4|mp3)$/i,
- loader: 'file-loader',
- },
- {
- test: /\.js$/,
- enforce: 'pre',
- exclude: /node_modules/,
- loader: 'eslint-loader',
- },
- {
- test: /\.js$/,
- exclude: /node_modules/,
- loader: 'babel-loader',
- },
- {
- test: /\.vue$/,
- loader: 'vue-loader',
- },
- ],
- },
- externals: {
- vue: 'Vue',
- },
- resolve: {
- extensions: [
- '.js',
- '.vue',
- ],
- alias: {
- '@': path.resolve(__dirname, '../../src'),
- },
- },
- devtool: 'inline-source-map',
- plugins: [
- new HtmlWebpackPlugin({
- template: config.template,
- }),
- new VueLoaderPlugin(),
- new webpack.DefinePlugin({
- 'process.env': config.dev.env,
- }),
- new webpack.HotModuleReplacementPlugin(),
- new FriendlyErrorsWebpackPlugin({
- compilationSuccessInfo: {
- messages: [
- `http://localhost:${config.port} or http://${ip.address()}:${config.port}`,
- ],
- },
- }),
- ],
- }
|