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

  • 相关阅读:
    多组件共享-vuex
    在子组件中触发事件,传值给父组件-vue
    在父组件中,直接获取子组件数据-vue
    非父子组件通过事件传值-vue
    在父组件中,传值给子组件-vue
    MVVM
    Virtual DOM-渲染函数render -vue
    duilib入门简明教程 -- VS环境配置(2) (转)
    duilib入门简明教程 -- 前言(1) (转)
    【CDockablePane】关于CDockablePane
  • 原文地址:https://www.cnblogs.com/Searchor/p/13491109.html
Copyright © 2011-2022 走看看