其他分享
首页 > 其他分享> > Vue学习笔记---webpack概念

Vue学习笔记---webpack概念

作者:互联网

1.作用

2.核心概念

3.入口起点

4.输出

5.loader

module: {
    rules: [
        {
            test: /\.js$/,
            exclude: /node_modules/,
            include: [resolve('src')],
            use: 'Happypack/loader?id=js'
        },
        {
            test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
            loader: 'url-loader',
            options: {
                esModule: false,
                limit: 10000,
                name: utils.assetsPath('img/[name].[hash:7].[ext]')
            }
        }
    ]
}

6.插件

plugins: [
    new HtmlWebpackPlugin({
        excludeChunks: ['ui-preview'],
        template: './src/main/index.ejs',
        filename: './index.html',
        favicon: './public/favicon/favicon.ico',
        title: version.CONFIG_VERSION_NAME,
        inject: false,
        hash: true,
        mode: devMode //是否是调试模式 'development'
    })
] 

7.模块解析

resolve: {
    extensions: ['.js', '.json', '.vue'], 
    modules: [
        resolve('src'),
        resolve('node_modules')
    ],
    alias: {
        '@': path.resolve(__dirname, "../src"),
    }
}

8.manifest

9.模块热替换

const webpackDevServer = require('webpack-dev-server');
const webpack = require('webpack');

const config = require('./webpack.config.js');
const options = {
  contentBase: './dist',
  hot: true,
  host: 'localhost'
};

webpackDevServer.addDevServerEntrypoints(config, options);
const compiler = webpack(config);
const server = new webpackDevServer(compiler, options);

server.listen(5000, 'localhost', () => {
  console.log('dev server listening on port 5000');
});

标签:文件,Vue,HMR,js,---,webpack,模块,loader
来源: https://blog.csdn.net/qq_44242707/article/details/122528119