<small id='hQJx9'></small><noframes id='hQJx9'>

  • <tfoot id='hQJx9'></tfoot>
      <bdo id='hQJx9'></bdo><ul id='hQJx9'></ul>
    <legend id='hQJx9'><style id='hQJx9'><dir id='hQJx9'><q id='hQJx9'></q></dir></style></legend>
    <i id='hQJx9'><tr id='hQJx9'><dt id='hQJx9'><q id='hQJx9'><span id='hQJx9'><b id='hQJx9'><form id='hQJx9'><ins id='hQJx9'></ins><ul id='hQJx9'></ul><sub id='hQJx9'></sub></form><legend id='hQJx9'></legend><bdo id='hQJx9'><pre id='hQJx9'><center id='hQJx9'></center></pre></bdo></b><th id='hQJx9'></th></span></q></dt></tr></i><div id='hQJx9'><tfoot id='hQJx9'></tfoot><dl id='hQJx9'><fieldset id='hQJx9'></fieldset></dl></div>

        如何使用 gulp webpack-stream 生成正确的命名文件?

        时间:2023-05-28
          <bdo id='LTXpa'></bdo><ul id='LTXpa'></ul>
          • <i id='LTXpa'><tr id='LTXpa'><dt id='LTXpa'><q id='LTXpa'><span id='LTXpa'><b id='LTXpa'><form id='LTXpa'><ins id='LTXpa'></ins><ul id='LTXpa'></ul><sub id='LTXpa'></sub></form><legend id='LTXpa'></legend><bdo id='LTXpa'><pre id='LTXpa'><center id='LTXpa'></center></pre></bdo></b><th id='LTXpa'></th></span></q></dt></tr></i><div id='LTXpa'><tfoot id='LTXpa'></tfoot><dl id='LTXpa'><fieldset id='LTXpa'></fieldset></dl></div>

            <small id='LTXpa'></small><noframes id='LTXpa'>

                <legend id='LTXpa'><style id='LTXpa'><dir id='LTXpa'><q id='LTXpa'></q></dir></style></legend>
                  <tbody id='LTXpa'></tbody>

                <tfoot id='LTXpa'></tfoot>
                  本文介绍了如何使用 gulp webpack-stream 生成正确的命名文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  目前我们使用

                  我不能使用 c2212af8f732662acc64.js 我需要将其命名为 bundle.js 或其他正常名称.

                  我们的 Webpack 配置:

                  var webpack = require('webpack');var PROD = JSON.parse(process.env.PROD_DEV || '0');//http://stackoverflow.com/questions/25956937/how-to-build-minified-and-uncompressed-bundle-with-webpack模块.exports = {条目:./entry.js",开发工具:源地图",输出: {devtoolLineToLine:真,sourceMapFilename: "app/assets/js/bundle.js.map",路径信息:真,路径:__dirname,文件名:产品?app/assets/js/bundle.min.js":app/assets/js/bundle.js"},模块: {装载机:[{测试:/.css$/,加载器:style!css"}]},插件:产品?[新的 webpack.optimize.UglifyJsPlugin({minimize: true})]:[]};

                  解决方案

                  啊,我继续阅读 并想通了:

                  gulp.task('webpack', function() {返回 gulp.src('entry.js').pipe(webpack( 需要('./webpack.config.js') )).pipe(gulp.dest('app/assets/js'));});

                  ^ 在这里我可以传入我的实际 webpack.config,它会使用我已经在那里设置的路径.在我的情况下,我刚刚删除了 app/assets/js 因为我现在 gulp 中有该路径.

                  但仍然没有世俗的想法,为什么在我创建的第一个任务中,它会生成随机哈希文件名?

                  Currently we're using Webpack for our Module loader, and Gulp for everything else (sass -> css, and the dev/production build process)

                  I want to wrap the webpack stuff into gulp, so all I have to do is type gulp and it starts, watches and runs webpack and the rest of what our gulp is setup to do.

                  So I found webpack-stream and implemented it.

                  gulp.task('webpack', function() {
                      return gulp.src('entry.js')
                          .pipe(webpack({
                              watch: true,
                              module: {
                                  loaders: [
                                      { test: /.css$/, loader: 'style!css' },
                                  ],
                              },
                          }))
                          .pipe(gulp.dest('dist/bundle.js'));
                  });
                  

                  The problem is that it generates a random character name for the .js file, how are we suppose to use that in our app?

                  From the github repo:

                  The above will compile src/entry.js into assets with webpack into dist/ with the output filename of [hash].js (webpack generated hash of the build).

                  How do you rename these files? Also the new gulp task generates a new file everytime I save an edit:

                  I can't use c2212af8f732662acc64.js I need it to be named bundle.js or something else normal.

                  Our Webpack config:

                  var webpack = require('webpack');
                  var PROD = JSON.parse(process.env.PROD_DEV || '0');
                  // http://stackoverflow.com/questions/25956937/how-to-build-minified-and-uncompressed-bundle-with-webpack
                  
                  module.exports = {
                      entry: "./entry.js",
                      devtool: "source-map",
                      output: {
                          devtoolLineToLine: true,
                          sourceMapFilename: "app/assets/js/bundle.js.map",
                          pathinfo: true,
                          path: __dirname,
                          filename: PROD ? "app/assets/js/bundle.min.js" : "app/assets/js/bundle.js"
                      },
                      module: {
                          loaders: [
                              { test: /.css$/, loader: "style!css" }
                          ]
                      },
                      plugins: PROD ? [
                          new webpack.optimize.UglifyJsPlugin({minimize: true})
                      ] : []
                  };
                  

                  解决方案

                  Ah I read on a bit further and figured it out:

                  gulp.task('webpack', function() {
                      return gulp.src('entry.js')
                      .pipe(webpack( require('./webpack.config.js') ))
                      .pipe(gulp.dest('app/assets/js'));
                  });
                  

                  ^ here I can just pass in my actual webpack.config and it will use the paths I have already set in there. In my case I just removed app/assets/js since I have that path in now gulp instead.

                  Still no earthly idea though, why with the first task I created, it generates random hash filenames?

                  这篇关于如何使用 gulp webpack-stream 生成正确的命名文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  • <tfoot id='Jc9iI'></tfoot>
                      <tbody id='Jc9iI'></tbody>

                      1. <i id='Jc9iI'><tr id='Jc9iI'><dt id='Jc9iI'><q id='Jc9iI'><span id='Jc9iI'><b id='Jc9iI'><form id='Jc9iI'><ins id='Jc9iI'></ins><ul id='Jc9iI'></ul><sub id='Jc9iI'></sub></form><legend id='Jc9iI'></legend><bdo id='Jc9iI'><pre id='Jc9iI'><center id='Jc9iI'></center></pre></bdo></b><th id='Jc9iI'></th></span></q></dt></tr></i><div id='Jc9iI'><tfoot id='Jc9iI'></tfoot><dl id='Jc9iI'><fieldset id='Jc9iI'></fieldset></dl></div>
                      2. <small id='Jc9iI'></small><noframes id='Jc9iI'>

                        <legend id='Jc9iI'><style id='Jc9iI'><dir id='Jc9iI'><q id='Jc9iI'></q></dir></style></legend>
                          <bdo id='Jc9iI'></bdo><ul id='Jc9iI'></ul>