app/etc/di.xml: 새 항목 추가 stategiesList:
<virtualType name="developerMaterialization" type="Magento\Framework\App\View\Asset\MaterializationStrategy\Factory">
<arguments>
<argument name="strategiesList" xsi:type="array">
<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>
<item name="default" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>
/* ++ */ <item name="asset" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</item>
</argument>
</arguments>
</virtualType>
개발자 모드에 있다고 가정하면 pub/static브라우저에서 컨텐츠를 삭제하고 페이지로 이동하면 magento가 정적 컨텐츠를 재생성합니다.
Magento 2.1.4에서 나를 위해 일했습니다 (styles-m.css가 생성되고 다른 파일이 심볼 링크되었습니다).
모든 마법은 vendor/magento/framework/App/View/Asset/MaterializationStrategy/Factory.php다음 에서 발생합니다 .
public function create(Asset\LocalInterface $asset)
{
if (empty($this->strategiesList)) {
$this->strategiesList[] = $this->objectManager->get(self::DEFAULT_STRATEGY);
}
foreach ($this->strategiesList as $strategy) {
if ($strategy->isSupported($asset)) {
return $strategy;
}
}
throw new \LogicException('No materialization strategy is supported');
}
Magento는 stategiesList항목을 반복 하고 자산을 지원하는 첫 번째 상태를 사용합니다.
프로덕션 모드에서 작동시키는 방법?
면책 조항 : 이 핵에는 핵심 파일 편집이 포함되어 있습니다. 조심하십시오.
모두 마 젠토 2.1.4에서 테스트
- 정적 파일에서 버전 번호를 제거하십시오.
Stores > Configuration > Advanced > Developer > Static Files Settings > No
기능을 다음과 같이 편집 vendor/magento/framework/App/StaticResource.php하고 작성 launch하십시오.
public function launch()
{
// disabling profiling when retrieving static resource
\Magento\Framework\Profiler::reset();
$appMode = $this->state->getMode();
/*if ($appMode == \Magento\Framework\App\State::MODE_PRODUCTION) {
$this->response->setHttpResponseCode(404);
} else {*/
$path = $this->request->get('resource');
$params = $this->parsePath($path);
$this->state->setAreaCode($params['area']);
$this->objectManager->configure($this->configLoader->load($params['area']));
$file = $params['file'];
unset($params['file']);
$asset = $this->assetRepo->createAsset($file, $params);
$this->response->setFilePath($asset->getSourceFile());
$this->publisher->publish($asset);
/*}*/
return $this->response;
}
pub/static브라우저에서 컨텐츠를 삭제 하고 상점 URL을 방문하십시오.