<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WebPack | SDT 攻城獅區</title>
	<atom:link href="https://sdt.hameba.tw/tag/webpack/feed/" rel="self" type="application/rss+xml" />
	<link>https://sdt.hameba.tw</link>
	<description>由Steven, Der, Ted 三位高級打字員所組成，是三位工程師(攻城獅)所維護的技術分享平台，或許偶爾會分享一些日常，有任何問題或是錯誤的部分，歡迎留言告訴我們！</description>
	<lastBuildDate>Thu, 05 Mar 2020 01:59:34 +0800</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.3</generator>

<image>
	<url>https://sdt.hameba.tw/wp-content/uploads/2020/02/hameba_favicon-150x150.png</url>
	<title>WebPack | SDT 攻城獅區</title>
	<link>https://sdt.hameba.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Webpack 打包移除warning及console.log的方式</title>
		<link>https://sdt.hameba.tw/635/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=webpack-%25e6%2589%2593%25e5%258c%2585%25e7%25a7%25bb%25e9%2599%25a4warning%25e5%258f%258aconsole-log%25e7%259a%2584%25e6%2596%25b9%25e5%25bc%258f</link>
				<comments>https://sdt.hameba.tw/635/#respond</comments>
				<pubDate>Thu, 05 Mar 2020 01:40:26 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[uglifyjs-webpack-plugin]]></category>
		<category><![CDATA[WebPack]]></category>
		<category><![CDATA[webpack.optimize.UglifyJsPlugin]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=635</guid>
				<description><![CDATA[<p>Webpack打包成Product時需要自動把Warning跟log給移除。 可以在plugin加入參數即可， &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/635/" class="more-link">閱讀全文<span class="screen-reader-text">〈Webpack 打包移除warning及console.log的方式〉</span></a></p>
The post <a href="https://sdt.hameba.tw/635/">Webpack 打包移除warning及console.log的方式</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>Webpack打包成Product時需要自動把Warning跟log給移除。</p>
<p>可以在plugin加入參數即可，v4跟v2版本有很大的差異。<span id="more-635"></span></p>
<p>在此提供兩種版本的方式。</p>
<p>Webpack v4</p><pre class="crayon-plain-tag">// 需引入uglifyjs-webpack-plugin,這邊與v2就不一樣
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
plugins: [
    new UglifyJsPlugin({
        sourceMap: true,
        uglifyOptions: {
            ie8: false,
            ecma: 8,
            parse: {},
            mangle: true,
            output: {
                comments: false,
                beautify: false
            },
            compress: true,
            warnings: false
            }
    })
]</pre><p>Webpack v2</p><pre class="crayon-plain-tag">// v2 版本直接使用webpack.optimize即可
plugins: [
    new webpack.optimize.UglifyJsPlugin({
        sourceMap: true,
        compress: {
            warnings: false, // remove 警告
            drop_console: true // 移除console.log
        }
    })
]</pre><p>&nbsp;</p>
<p>Reference</p>
<p><a href="https://blog.csdn.net/xiaoguang44/article/details/89555376" target="_blank" rel="noopener noreferrer">https://blog.csdn.net/xiaoguang44/article/details/89555376</a></p>
<p><a href="https://blog.csdn.net/xiasohuai/article/details/88527483" target="_blank" rel="noopener noreferrer">https://blog.csdn.net/xiasohuai/article/details/88527483</a></p>
<p><a href="https://segmentfault.com/a/1190000015032321" target="_blank" rel="noopener noreferrer">https://segmentfault.com/a/1190000015032321</a></p>The post <a href="https://sdt.hameba.tw/635/">Webpack 打包移除warning及console.log的方式</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/635/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>DeprecationWarning: Chunk.modules is deprecated. Use Chunk.getNumberOfModules/mapModules/forEachModule/containsModule instead.</title>
		<link>https://sdt.hameba.tw/612/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=deprecationwarning-chunk-modules-is-deprecated-use-chunk-getnumberofmodules-mapmodules-foreachmodule-containsmodule-instead</link>
				<comments>https://sdt.hameba.tw/612/#respond</comments>
				<pubDate>Sat, 29 Feb 2020 01:10:49 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[extract-text-webpack-plugin]]></category>
		<category><![CDATA[mini-css-extract-plugin]]></category>
		<category><![CDATA[WebPack]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=612</guid>
				<description><![CDATA[<p>webpack打包又出現問題，單純看提示訊息又不知道是哪個套件造成chunk的問題， DeprecationW &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/612/" class="more-link">閱讀全文<span class="screen-reader-text">〈DeprecationWarning: Chunk.modules is deprecated. Use Chunk.getNumberOfModules/mapModules/forEachModule/containsModule instead.〉</span></a></p>
The post <a href="https://sdt.hameba.tw/612/">DeprecationWarning: Chunk.modules is deprecated. Use Chunk.getNumberOfModules/mapModules/forEachModule/containsModule instead.</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>webpack打包又出現問題，單純看提示訊息又不知道是哪個套件造成chunk的問題，</p>
<p>DeprecationWarning: Chunk.modules is deprecated. Use Chunk.getNumberOfModules/mapModules/forEachModule/containsModule instead.<span id="more-612"></span></p>
<p><img class="alignnone size-large wp-image-613" src="https://sdt.hameba.tw/wp-content/uploads/2020/02/截圖-2020-02-29-上午9.07.21-1024x90.png" alt="" width="840" height="74" srcset="https://sdt.hameba.tw/wp-content/uploads/2020/02/截圖-2020-02-29-上午9.07.21-1024x90.png?v=1582938458 1024w, https://sdt.hameba.tw/wp-content/uploads/2020/02/截圖-2020-02-29-上午9.07.21-300x26.png?v=1582938458 300w, https://sdt.hameba.tw/wp-content/uploads/2020/02/截圖-2020-02-29-上午9.07.21-768x68.png?v=1582938458 768w, https://sdt.hameba.tw/wp-content/uploads/2020/02/截圖-2020-02-29-上午9.07.21-1536x135.png?v=1582938458 1536w, https://sdt.hameba.tw/wp-content/uploads/2020/02/截圖-2020-02-29-上午9.07.21-1200x106.png?v=1582938458 1200w, https://sdt.hameba.tw/wp-content/uploads/2020/02/截圖-2020-02-29-上午9.07.21.png?v=1582938458 1956w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p>查詢要更新哪個套件，更新node_module後即可，</p><pre class="crayon-plain-tag">$ npm install extract-text-webpack-plugin@3</pre><p>npm 上面也已經提示不推薦使用，沒有在維護了！</p>
<p><a href="https://www.npmjs.com/package/extract-text-webpack-plugin">extract-text-webpack-plugin</a></p>
<p>&#8220;建議改使用&#8221;</p>
<p><a href="https://www.npmjs.com/package/mini-css-extract-plugin">mini-css-extract-plugin</a></p>
<p>&nbsp;</p>
<p>Reference</p>
<p><a href="https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/529" target="_blank" rel="noopener noreferrer">https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/529</a></p>The post <a href="https://sdt.hameba.tw/612/">DeprecationWarning: Chunk.modules is deprecated. Use Chunk.getNumberOfModules/mapModules/forEachModule/containsModule instead.</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/612/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>parseQuery() will be replaced with getOptions() in the next major version of loader-utils</title>
		<link>https://sdt.hameba.tw/609/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=parsequery-will-be-replaced-with-getoptions-in-the-next-major-version-of-loader-utils</link>
				<comments>https://sdt.hameba.tw/609/#respond</comments>
				<pubDate>Sat, 29 Feb 2020 01:04:41 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[babel-loader]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[WebPack]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=609</guid>
				<description><![CDATA[<p>做webpack打包時看見此錯誤訊息，也不知道是哪裡出問題， (node:36968) Deprecation &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/609/" class="more-link">閱讀全文<span class="screen-reader-text">〈parseQuery() will be replaced with getOptions() in the next major version of loader-utils〉</span></a></p>
The post <a href="https://sdt.hameba.tw/609/">parseQuery() will be replaced with getOptions() in the next major version of loader-utils</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>做webpack打包時看見此錯誤訊息，也不知道是哪裡出問題，</p>
<p>(node:36968) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56<br />
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.<span id="more-609"></span></p>
<p><img class="alignnone size-large wp-image-610" src="https://sdt.hameba.tw/wp-content/uploads/2020/02/截圖-2020-02-29-上午8.57.45-1024x84.png" alt="" width="840" height="69" srcset="https://sdt.hameba.tw/wp-content/uploads/2020/02/截圖-2020-02-29-上午8.57.45-1024x84.png?v=1582937889 1024w, https://sdt.hameba.tw/wp-content/uploads/2020/02/截圖-2020-02-29-上午8.57.45-300x25.png?v=1582937889 300w, https://sdt.hameba.tw/wp-content/uploads/2020/02/截圖-2020-02-29-上午8.57.45-768x63.png?v=1582937889 768w, https://sdt.hameba.tw/wp-content/uploads/2020/02/截圖-2020-02-29-上午8.57.45-1536x125.png?v=1582937889 1536w, https://sdt.hameba.tw/wp-content/uploads/2020/02/截圖-2020-02-29-上午8.57.45-2048x167.png?v=1582937889 2048w, https://sdt.hameba.tw/wp-content/uploads/2020/02/截圖-2020-02-29-上午8.57.45-1200x98.png?v=1582937889 1200w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p>並非webpack prod錯誤，而是套件太舊，查一下package.json以為是loader.utils.</p>
<p>結果node_module沒有這套件上查了，是<span style="color: #ff0000">babel-loader</span>這套件。</p>
<p>跳出這錯誤是我用6.x.x版本，直接升級上去會到8.x.x版本，又會跳出babel-core的問題，</p>
<p>所以我改成指定 7.x.x版本</p><pre class="crayon-plain-tag">$ npm install babel-loader@7</pre><p>&nbsp;</p>
<p>Reference</p>
<p><a href="https://github.com/babel/babel-loader/issues/392" target="_blank" rel="noopener noreferrer">https://github.com/babel/babel-loader/issues/392</a></p>The post <a href="https://sdt.hameba.tw/609/">parseQuery() will be replaced with getOptions() in the next major version of loader-utils</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/609/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>React webpack v3 升級 v4 錯誤訊息</title>
		<link>https://sdt.hameba.tw/495/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=react-webpack-v3-%25e5%258d%2587%25e7%25b4%259a-v4</link>
				<comments>https://sdt.hameba.tw/495/#respond</comments>
				<pubDate>Sun, 26 Jan 2020 16:20:51 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[react]]></category>
		<category><![CDATA[v3]]></category>
		<category><![CDATA[v4]]></category>
		<category><![CDATA[WebPack]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=495</guid>
				<description><![CDATA[<p>今天嘗試將就專案的webpack從v3升到v4，結果webpack-dev-middleware，一開啟一直跳 &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/495/" class="more-link">閱讀全文<span class="screen-reader-text">〈React webpack v3 升級 v4 錯誤訊息〉</span></a></p>
The post <a href="https://sdt.hameba.tw/495/">React webpack v3 升級 v4 錯誤訊息</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>今天嘗試將就專案的webpack從v3升到v4，結果webpack-dev-middleware，一開啟一直跳出此錯誤訊息：</p>
<p><span id="more-495"></span></p>
<p>You are currently using minified code outside of NODE_ENV === &#8216;production&#8217;. This means that you are running a slower development build of Redux. You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) to ensure you have the correct code for your production build.</p>
<p>找了很多文章，都是說在webpack.config.js加上此句，</p><pre class="crayon-plain-tag">new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: JSON.stringify('development')
            }
        })</pre><p>或是將react-router從v3升級v4，但我原本就使用4.0.0了，但還是嘗試升級看看，</p>
<p>反而我從4.0.0升到4.0.5又出現其他錯誤訊息，只好將回4.0.0版本，</p>
<p>不管怎麼在設定檔案上做NODE_ENV的參數，都會報錯，</p>
<p>後來看到此command設定：</p><pre class="crayon-plain-tag">"dev": "webpack --mode development",

    "build": "webpack --mode production"</pre><p>好像可以解決我的問題，但我又發現我是使用webpack-dev-middleware，</p>
<p>並沒有地方可以設定command，幸好在原本的webpack.config.js可以加上此參數</p>
<p><span style="color: #ff0000"> mode:&#8221;development&#8221;</span></p><pre class="crayon-plain-tag">module.exports = {
    mode:"development",
    //入口文件
    entry:{
        'webpack-hot-middleware/client',
        path.resolve(__dirname, 'react')
    },
...
...</pre><p>設定完後，重新啟動start:dev，就沒有在跑出此錯誤訊息了！</p>
<p>mode此參數為v4所新增的。</p>
<p>&nbsp;</p>
<p>Reference</p>
<p><a href="https://blog.csdn.net/jiang7701037/article/details/80682662" target="_blank" rel="noopener noreferrer">https://blog.csdn.net/jiang7701037/article/details/80682662</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>The post <a href="https://sdt.hameba.tw/495/">React webpack v3 升級 v4 錯誤訊息</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/495/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
	</channel>
</rss>
