• webpack


    const path = require('path');
    const HtmlWebpackPlugin = require('html-webpack-plugin'); //installed via npm
    const webpack = require('webpack'); //to access built-in plugins
    
    module.exprots = {
        //development production none
        mode: 'development',
    
        //=============================================================================//
                                            Entry point
        //=============================================================================//
        entry: './path/to/my/entry/file.js',
        /*
        entry: {
            main: './path/to/my/entry/file.js'
        }
    
        entry: {
            app: './src/app.js',
            adminApp: './src/adminApp.js'
        }
        */
    
        //=============================================================================//
                                            Project Output
        //=============================================================================//
        output: {
            path: path.resolve(__dirname, 'dist'),
            filename: 'my-first-webpack.bundle.js'
            //filename: '[name].bundle.js'
            //filename: '[name].[contentHash].bundle.js'
            //path: '/home/proj/cdn/assets/[hash]',
        },
    
        /*
        output: {
            filename: '[name].js',
            path: __dirname + '/dist'
        }
        */
    
        //=============================================================================//
                                            Loaders
        //=============================================================================//
        module: {
            rules: [
                { test: /.ts$/, use: 'ts-loader' }
                {
                    test: /.css$/,
                    use: [
                      { loader: 'style-loader' },
                      {
                        loader: 'css-loader',
                        options: {
                          modules: true
                        }
                      },
                      { loader: 'sass-loader' }
                    ]
                }
                //test property identifies which file or files should be transformed
                //use property indicates which loader should be used to do the transforming
            ]
            //Hey webpack compiler, when you come across a path that resolves to a '.txt' file
            //inside of a require()/import statement,
            //use the raw-loader to transform it before you add it to the bundle
            //Loaders are evaluated/executed from right to left (or from bottom to top)
        },
    
        //=============================================================================//
                                            Plugins
        //=============================================================================//
        //A webpack plugin is a JavaScript object that has an apply method. 
        //This apply method is called by the webpack compiler, 
        //giving access to the entire compilation lifecycle.
        plugins: [
            new HtmlWebpackPlugin({template: './src/index.html'})
        ]
        
        /*
        watch: true,
        watchOptions: {
            ignored: ['files/**/*.js', 'node_modules/**']
        }
        */
    };
    
    

    https://webpack.js.org/configuration/

    https://github.com/ruanyf/webpack-demos

  • 相关阅读:
    bootstrap添加多个模态对话框支持
    突然想写书
    几个常用的内存、CPU飙高 分析工具
    steeltoe学习
    thrift简单使用
    记一次线上Mysql数据库 宕机
    .NetCore 开发生产环境项目前的思考&&踩坑
    SOA(面向服务架构)——踩坑后反思:这样值得吗?
    ProtoBuf与Newtonsoft序列化反序列化性能对比
    SimpleInjector 简单使用
  • 原文地址:https://www.cnblogs.com/Searchor/p/13491109.html
Copyright © 2020-2023  润新知