<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] > [在github 參考源碼](https://github.com/idcpj/vue-mall/tree/master/webpack_demo) ## 目錄結構 ``` src ├── cart.html ├── index.html └── js ├── cart.js ├── common.js └── index.js ``` ## 運行 ``` npm init npm install webpack --save-dev ``` ## 安裝常用插件 ### 編譯 html [html-webpack-plugin](https://www.npmjs.com/package/html-webpack-plugin) ``` new HtmlWebpackPlugin({ filename:"cart.html", template:"./src/cart.html", chunks:['cart'], minify:{ //壓縮 html 代碼 removeComments:true, collapseWhitespace:true } }), ``` ### 編譯前先刪除文件 [clean-webpack-plugin](https://github.com/johnagan/clean-webpack-plugin) ``` new CleanWebpackPlugin(['./dist'],{ root:path.join(__dirname,''), verbose:true, dry:false, }), ``` ### css-loader,style-loader ``` npm install --save-dev css-loader style-loader extract-text-webpack-plugin //需要在頁面的 js 中引入 css ,如 index.js import "../css/index.css"; //webpack.config.js module: { rules: [ { test: /\.css$/, use: [ 'style-loader', 'css-loader' ] } ] } ``` ### es6 ``` npm install -D babel-loader @babel/core @babel/preset-env //webpack.config.js rules: [ { test: /\.m?js$/, exclude: /(node_modules|bower_components)/, use: { loader: 'babel-loader', options: { presets: ['@babel/preset-env'] } } } ] ``` ### 使用 jquery [npm 官網](https://www.npmjs.com/package/jquery) ``` npm i jquery //index.js define(["jquery"], function($) { //code }); ``` ### uglifyjs-webpack-plugin js 壓縮 [npm 官網](https://www.npmjs.com/package/webpack-parallel-uglify-plugin) ``` const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); module.exports = { //... optimization: { minimizer: [new UglifyJsPlugin()] } }; ``` ## 技巧 ### js 最好以模塊形式引入 如 ``` //common.js define("common",function () { return { initIndex:function () { console.log("common init index"); }, initCart:function () { console.log("common init cart"); } } }); //index.js require(['./common.js'],function (common) { common.initIndex(); }); ``` ### webpack.config.js 設置 ``` entry: { index:"./src/js/index.js", //設置多入口 cart:'./src/js/cart.js', }, devtool:"#source-map" //用于調試 ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看