@snack-kit/scripts 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/bin/snack-scripts.js +6 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -189,6 +189,10 @@ module.exports = (config, webpack) => {
|
|
|
189
189
|
|
|
190
190
|
## Changelog
|
|
191
191
|
|
|
192
|
+
### 0.9.1
|
|
193
|
+
|
|
194
|
+
- 修复:`snack-scripts` 命令在宿主项目中执行报 `ENOENT` 的问题,改用 `require.resolve` 动态定位 `webpack-cli`,兼容 npm hoist 和非 hoist 两种安装场景
|
|
195
|
+
|
|
192
196
|
### 0.9.0
|
|
193
197
|
|
|
194
198
|
- 修复:sass-loader 改回 legacy API,解决旧项目 `@import '~xxx'` 路径无法解析的问题(`api: 'modern'` 的 webpack importer 在 sass-loader 13.x 中未实现)
|
package/bin/snack-scripts.js
CHANGED
|
@@ -34,18 +34,19 @@ const loaderConfigPath = path.resolve(__dirname, '../config/webpack.loader.confi
|
|
|
34
34
|
const devConfigPath = path.resolve(__dirname, '../config/webpack.dev.config.js');
|
|
35
35
|
const entryConfigPath = path.resolve(__dirname, '../config/webpack.entry.config.js');
|
|
36
36
|
|
|
37
|
-
const platform = process.platform;
|
|
38
|
-
const webpackFile = platform === 'win32' ? 'webpack.cmd' : 'webpack';
|
|
39
|
-
|
|
40
37
|
// 始终使用 snack-scripts 自身内置的 webpack CLI,保证 CLI 进程与配置文件加载同一 webpack 实例,
|
|
41
38
|
// 避免与宿主项目 node_modules 中的 webpack 产生多实例 tapable 冲突。
|
|
42
|
-
|
|
39
|
+
// 使用 require.resolve 动态查找,兼容 npm hoist(依赖被提升到宿主项目根 node_modules)和
|
|
40
|
+
// 未 hoist(保留在 @snack-kit/scripts/node_modules)两种情况。
|
|
41
|
+
const webpackCliBin = require.resolve('webpack-cli/bin/cli.js', {
|
|
42
|
+
paths: [path.resolve(__dirname, '../')]
|
|
43
|
+
});
|
|
43
44
|
|
|
44
45
|
// ─── webpack 构建命令 ─────────────────────────────────────────────────────────
|
|
45
46
|
|
|
46
47
|
function execWebpack(wpArgs) {
|
|
47
48
|
return new Promise(resolve => {
|
|
48
|
-
const ps = spawn(
|
|
49
|
+
const ps = spawn(process.execPath, [webpackCliBin, ...wpArgs], { stdio: 'inherit' });
|
|
49
50
|
ps.on('error', e => { console.log(e); resolve(false); });
|
|
50
51
|
ps.on('exit', () => resolve(true));
|
|
51
52
|
});
|