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

  • 相关阅读:
    用互不相同的fib数列的数分解任意整数。
    2015 初赛TG 错题解析
    【模板】判断二叉查找树
    【初赛】完善程序题解题技巧 && 近六年PJ完善程序真题解析
    [NOIP 2012普及组 No.2] 寻宝
    [NOIP 2012普及组 No.1] 质因数分解
    [NOIP 2013普及组 No.4] 车站分级
    [NOIP 2013普及组 No.3] 小朋友的数字
    [NOIP 2013普及组 No.2] 表达式求值
    [NOIP 2013普及组 No.1] 计数问题
  • 原文地址:https://www.cnblogs.com/Searchor/p/13491109.html
Copyright © 2011-2022 走看看