美文网首页
webpack-Learning

webpack-Learning

作者: Outlier__ | 来源:发表于2019-04-25 16:33 被阅读0次

    Install:

    Global:

    npm i webpack -g

    Local:

    npm i webpack --save-dev

    Pack assests to bundle

    via command line:

    webpack src/js/main.js --output dist/js/bundle.js --mode development

    via npx

    npx webpack

    config common options

    config file:

    webpack.config.js

    common options:

    const path = require('path');  
    module.exports={  
        entry:"./src/index.js",  
        output: {  
            filename: "bundle.js",  
            path: path.resolve(__dirname,'dist')  
        },  
        devServer: {  
      
        },  
        module: {  
            rules: [  
                {  
                    test:/\.css$/,  
                    use:[  
                        {loader: "style-loader"},  
                        {loader: "css-loader"},  
                    ],  
                },  
                {  
                    test:/\.less$/,  
                    use:[  
                        {loader: "style-loader"},  
                        {loader: "css-loader"},  
                        {loader: "less-loader"},  
                    ],  
                },  
                {  
                    test:/\.scss$/,  
                    use:[  
                        {loader: "style-loader"},  
                        {loader: "css-loader"},  
                        {loader: "sass-loader"},  
                    ],  
                },  
            ]  
        },  
        plugins: [],  
        mode: "development", //生产模式:production  
        resolve: {  
      
        },  
    };
    

    相关文章

      网友评论

          本文标题:webpack-Learning

          本文链接:https://www.haomeiwen.com/subject/nbczgqtx.html