Chodzę z tym w kółko od jakiegoś czasu i myślę, że czas sięgnąć po pomoc.
Mam dziwny przypadek użycia, w którym muszę przetransponować maszynopis do jednego pakietu, pakować .css do jednego pliku, a także kopiować wszystkie dodatkowe pliki, które nie są .js, .ts lub .css. Te pliki są ostatecznie zapisywane na serwerze, z którego będzie korzystać oprogramowanie, którego używamy do naszych formularzy. Nie mogą zawierać pliku .html, więc większość zasobów, które znalazłem w Internecie, tak naprawdę nie pasuje do mojego przypadku użycia.
Z jakiegoś powodu pojawia się błąd i tak naprawdę nie wiem, dokąd mam iść.
Moje zależności od deweloperów są następujące:
"extract-text-webpack-plugin": "^3.0.2",
"ts-loader": "^6.2.1",
"typescript": "^3.7.2",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
Mój webpack.config.js wygląda następująco:
const path = require('path');
const glob = require('glob');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const combineLoaders = require('webpack-combine-loaders');
module.exports = {
entry: glob.sync('./forms/**/index.ts').reduce((acc, path) => {
const entry = path.replace('/index.ts', '')
acc[entry] = path
return acc
}, {}),
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
experimentalWatchApi: true,
}
}
],
exclude: /node_modules/,
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract(
'style-loader',
combineLoaders([{
loader: 'css-loader',
query: {
modules: true,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
}])
)
}
]
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ],
},
output: {
filename: './[name]/customBundle.js',
path: path.resolve(__dirname, './public')
},
plugins: [
new ExtractTextPlugin('styles.css')
]
};
I oto błąd, który otrzymuję:
> ci-deploy-test@1.0.0 build C:\Users\userName\Documents\git-coding\ci-deploy-test
> webpack
(node:15584) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\webpack\lib\Chunk.js:866
throw new Error(
^
Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead
at Chunk.get (C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\webpack\lib\Chunk.js:866:9)
at C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\extract-text-webpack-plugin\dist\index.js:176:48
at Array.forEach (<anonymous>)
at C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\extract-text-webpack-plugin\dist\index.js:171:18
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:7:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\tapable\lib\Hook.js:154:20)
at Compilation.seal (C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\webpack\lib\Compilation.js:1342:27)
at compilation.finish.err (C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\webpack\lib\Compiler.js:675:18)
at hooks.finishModules.callAsync.err (C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\webpack\lib\Compilation.js:1261:4)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:24:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\tapable\lib\Hook.js:154:20)
at Compilation.finish (C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\webpack\lib\Compilation.js:1253:28)
at hooks.make.callAsync.err (C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\webpack\lib\Compiler.js:672:17)
at _done (eval at create (C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:9:1)
at _err0 (eval at create (C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:20:22)
at _addModuleChain (C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\webpack\lib\Compilation.js:1185:12)
at processModuleDependencies.err (C:\Users\userName\Documents\git-coding\ci-deploy-test\node_modules\webpack\lib\Compilation.js:1097:9)
at process._tickCallback (internal/process/next_tick.js:61:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ci-deploy-test@1.0.0 build: `webpack`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ci-deploy-test@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\userName\AppData\Roaming\npm-cache\_logs\2019-11-20T01_47_46_906Z-debug.log
AKTUALIZACJA: głównie działa. Teraz muszę również umieć obsługiwać pliki .scss.
const path = require('path');
const glob = require('glob');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
plugins: [
new MiniCssExtractPlugin({
filename: './[name]/customBundle.css',
chunkFilename: '[id].css',
ignoreOrder: false
})
],
entry: glob.sync('./forms/**/index.ts').reduce((acc, path) => {
const entry = path.replace('/index.ts', '');
acc[entry] = path;
return acc;
}, {}),
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
experimentalWatchApi: true
}
}
],
exclude: /node_modules/
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: process.env.NODE_ENV === 'development'
}
},
'css-loader'
]
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
output: {
filename: './[name]/customBundle.js',
path: path.resolve(__dirname, './public')
}
};
1 odpowiedź
Jest to najprawdopodobniej związane z używaniem ExtractTextPlugin z Webpack 4:
https://github.com/webpack-contrib/extract-text-webpack-plugin#usage
Przenieś swoją konfigurację do: https://github.com/webpack-contrib/mini -css-extract-plugin
Podobne pytania
Nowe pytania
css
CSS (Cascading Style Sheets) to język arkuszy stylów reprezentacji używany do opisywania wyglądu i formatowania dokumentów HTML (HyperText Markup Language), XML (Extensible Markup Language) i elementów SVG, w tym (ale nie tylko) kolorów, układu, czcionek, i animacje. Opisuje także, jak elementy powinny być renderowane na ekranie, na papierze, w mowie lub na innych mediach.