zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    [CF1398A-E] Codeforces Round 93
    bzoj3758 数数和bzoj3798 特殊的质数
    P4234 最小差值生成树
    [UOJ274] P6664 温暖会指引我们前行
    P4172 [WC2006]水管局长
    bzoj2959 长跑
    bzoj4998 星球联盟(lct+并查集维护动态双连通性)
    P1501 [国家集训队]Tree II
    link-cut-tree
    fhq-treap,splay 模板
  • 原文地址:https://www.cnblogs.com/Searchor/p/13491109.html
Copyright © 2011-2022 走看看