• webpack之es6转换


    配置webpack.config.js:

    const webpack = require('webpack');
    const HtmlWebpackPlugin = require('html-webpack-plugin');
    const ExtractTextPlugin = require('extract-text-webpack-plugin');
    
    
    module.exports = {
        entry: __dirname + '/src/main.js',
        output: {
            path: __dirname + '/build',
            filename: 'bundle.js'
        },
        devtool: 'eval-source-map', //调试工具
        devServer: {
            contentBase: './build',
            historyApiFallback: true, //不跳转
            inline: true //实时刷新
        },
        watch: true, //自动监听,修改后自动编译
        resolve: {
            extensions: ['.js', '.vue', '.json'],
            alias: {
                'vue$': 'vue/dist/vue.esm.js'
            }
        },
        module: {
            rules: [{
                    test: /.vue$/,
                    use: 'vue-loader'
                },
                {
                    test: /.js$/,
                    use: 'babel-loader'
                },
                {
                    test: /.css$/,
                    use: [{
                            loader: "style-loader" //计算样式插入页面
                        },
                        {
                            loader: "css-loader" //@import等导入样式
                        }
                    ]
                }
            ]
        },
        plugins: [
            new webpack.BannerPlugin('Create by Jabin'),
            new HtmlWebpackPlugin({
                template: __dirname + '/src/index.tpl.html'
            })
        ]
    }

    .babelrc

    {
        "presets": [
            "stage-2"
        ]
    }

    注意:json已集成,无需转换

  • 相关阅读:
    [12.19模拟赛]矩形|扫描线+set
    网 络
    数组(二维)
    数组
    02-线程的三种创建方式
    01-线程(概念篇)
    IO流-文件操作
    Serializable 可串行化接口
    PrintStream 类
    ObjectIntputStream / ObjectOutputStream 类
  • 原文地址:https://www.cnblogs.com/maoriaty/p/7828185.html
Copyright © 2020-2023  润新知