webpack encore inline Загрузка CSS стилей (без создания отдельных файлов)
Primary tabs
Чтобы CSS собирался внутрь JS файла, используйте вызов:
Encore.disableCssExtraction()
например:
Encore .setOutputPath('public/widget/') .setPublicPath('/widget') .addEntry('rental', './assets/js/react-widget/react-widget.js') .splitEntryChunks() .disableCssExtraction() // выключаем сборку CSS в отдельный файл! .enableSingleRuntimeChunk() .cleanupOutputBeforeBuild() .enableBuildNotifications() .enableSourceMaps() .enableVersioning(false) // выключаем добавление хэша для виджета! .configureBabel(babelConfigCallback, babelEncoreOptions) .enableSassLoader() .configureDefinePlugin(envPlugin) .enableReactPreset() // для работы с react.js .configureWatchOptions(configWatchOptionsCallback) .addAliases(pathAliases) ;
Цитата из исходного кода энкора:
/** * Call this if you don't want imported CSS to be extracted * into a .css file. All your styles will then be injected * into the page by your JS code. * * Internally, this disables the mini-css-extract-plugin * and uses the style-loader instead. * * @returns {Encore} */ disableCssExtraction() { webpackConfig.disableCssExtraction(); return this; }
- Log in to post comments
- 950 reads