2015-10-12 23 views
5

Sto provando a configurare la struttura di un progetto e vorrei eseguire tutto tramite webpack. Il mio progetto consiste in dattiloscritto (non è importante per questa domanda), crudo CSS, modelli HTML (angolare) e di un index.htmlConf. Webpack (file statici)

L'attuale struttura del progetto è:

- app 
-- components 
--- foo 
---- foo.html 
---- foo.css 
---- foo-ctrl.ts 
---- foo-directive.ts 
--- bar 
---- bar.html 
---- bar.css 
---- bar-ctrl.ts 
---- bar-directive.ts 
-- index.html 
-- site.css 
- dist 
- package.json 
- webpack.config.js 

l'output desiderato sarebbe (sotto dist)

- js 
-- bundle.js // or some other name 
- views 
-- foo.html // or foo/foo.html 
-- bar.html // or bar/bar.html 
- styles 
-- foo.css // or foo/foo.css 
-- bar.css // or bar/bar.css 
-- sites.css 
- index.html 

ho provato con raw-loader e file-loader inutilmente per spostare i file html.

Sono contento di come webpack stia raggruppando i file ts/js, ma non riesco a capire come spostare i file statici (html/css). Di seguito è quello che ho finora.

// webpack.config.js 
module.exports = { 
    entry: [ 
    './app/app.ts', 
    './app/index.html', 
    './app/foo/foo.html', 
    './app/bar/bar.html' 
    ], 
    output: { 
    path: './dist/', 
    filename: 'js/bundle.js' 
    }, 
    resolve: { 
    extensions: ['', '.webpack.js', '.web.js', '.ts', '.js'] 
    }, 
    module: { 
    loaders: [ 
     { test: /\.ts$/, loader: 'ts-loader' }, 
     { test: /\index.html$/, loader: 'file-loader?name=[name].[ext]' }, 
     { test: /(?:[^index.html]*).html/, loader: 'file-loader?name=views/[name].[ext]' } 
    ] 
    } 
}; 

NOTA: Lo so che non so molto su webpack e l'approccio che sto cercando di fare non può essere il percorso suggerito, quindi sono aperto al revamping l'intera struttura.

risposta

0

Se si dispone di accesso a my egghead series, si consiglia di guardare requiring templates.

In caso contrario, controllare this directive. Non è più necessario per templateUrl, basta richiedere il modello e viene sottolineato come una stringa.

+1

Impressionante ... ho dovuto modificare TS per consentire l'uso di 'require' https://twitter.com/jbrantly/status/653632121370726400 – Brocco